0

I am getting compilation errors when building my project with a makefile which I don't see when building using console.

I am using the prebuilt GNU toolchain for PowerPC.

Here is my makefile,

GCC_Assembler = powerpc-eabi-as
GCC_Compiler  = powerpc-eabi-gcc

Directory_Application :=$(argument)/Source_Files
Directory_Bootloader :=$(argument)/Source_Files
Directory_RAMBootloader :=$(argument)/Source_Files

Application_Source_Files := $(wildcard $(Directory_Application)/*.C)
Application_Source_Files_Objecs=$(Application_Source_Files:.C=.O)


default:  Build_Application
all:   Build_Application

Build_Application: $(Application_Source_Files_Objecs)


$(Application_Source_Files_Objecs) : %.O: %.C
$(GCC_Compiler)  -c $<   -o $@ -O1  -Wall -Wfatal-errors

It builds without errors when I try to build it using these commands.

CD %WORKSPACE%\Source Files
powerpc-eabi-gcc    debug.c       -c -odebug.o    -O1 -Wall -Wfatal-errors
powerpc-eabi-gcc    io.c          -c -oio.o       -O1 -Wall -Wfatal-errors
...
...

So, when building using makefile, I get an error for a function that is not declared correctly. See the image below

Error( Makefile )

/Debug.C: infunction 'void display_task_table()':
/Debug.C:627:18: error: 'task_wait' was not declared in this scope
task_wait(100*2);

I only get warning for the same function when compiling without makefile.

Warning( Console )

Debug.C: in function 'display_task_table':
Debug.c:627:3: warning: implicit declaration of function 'task_wait' [-    Wimplicit-function-declaration]
task_wait(100*2);

I can fix the error by including the proper header file, but I would like to know why?

Please let me know if I need to include anything else

rajan
  • 13
  • 3
  • 2
    Please post the errors in your question itself, not as images. – user657267 Oct 03 '16 at 13:29
  • Looks like you're missing the signature for your `task_await` function – BackDoorNoBaby Oct 03 '16 at 13:30
  • If you don't want the makefile to fail on a warning, see this link: http://stackoverflow.com/questions/2414242/gcc-make-how-to-disable-fail-on-warning – BackDoorNoBaby Oct 03 '16 at 13:33
  • 1
    Older C standards allowed implicit functions declarations. In newer version of the standard, like C99, C11 (and in C++), it is an error. So my best bet is that when you compile in the console you are compiling in C89 mode. From the information provided I don't know why you get different results. See http://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c – Klas Lindbäck Oct 03 '16 at 13:39
  • Is there anyway to force the makefile to use C89. I tried -std=c89 flag, but it is still giving the error. – rajan Oct 03 '16 at 14:00
  • 1
    I think the main question here is what is the difference between manual invocation of gcc and when the gcc is invoked by make. I see no difference at least in command line arguments so far... – igagis Oct 03 '16 at 14:34

1 Answers1

1

Well, you are using .C extension when compiling with the Makefile, so the compiler is interpreting the file as a C++ source file and in C++, not having a prototype is an error (and only a warning in C) Just rewrite the line

$(Application_Source_Files_Objecs) : %.O: %.C

to

$(Application_Source_Files_Objecs) : %.o: %.c

and try again (and don't use an Operating System that doesn't distinguish case of letters :) <--- this was a joke, don't flame, please)

EDIT

Please, do the same with all the lines that specify .C and .O files also to .c and .o instead. The operating system doesn't bother with the case of characters, but make(1) and gcc(1) do.

Community
  • 1
  • 1
Luis Colorado
  • 10,974
  • 1
  • 16
  • 31