User forums > Using Code::Blocks
Compiler Q's
grv575:
Whether printf() is a builtin or not, it still requires the prototype: #include <stdio.h> is needed or I get an error on mingw.
vserghi:
I've been to the GNU GCC web site and had a look at the compiler options.
It is not immediatley obvious, which switches are being set when I place a check marks against some of the compiler options in C::B? I seem to remember another thread discussing something about giving users a description of what the options do, or maybe even what switch is being used for that compiler option.
Will this be a feature at somepoint?
Vasilis.
thomas:
--- Quote from: grv575 on August 08, 2005, 07:28:27 am ---Whether printf() is a builtin or not, it still requires the prototype: #include <stdio.h> is needed or I get an error on mingw.
--- End quote ---
Really? :)
--- Code: ---D:\desktop>echo main(){printf("blah");} > test.c
D:\desktop>gcc test.c -o test.exe
D:\desktop>test.exe
blah
D:\desktop>
--- End code ---
Urxae:
You're both right, sort of:
--- Code: ---D:\Temp> echo main(){printf("blah");} > test.c
D:\Temp> gcc -o test.exe test.c
D:\Temp> test
blah
D:\Temp> echo main(){printf("blah");} > test.cpp
D:\Temp> g++ -o test2.exe test.cpp
test.cpp: In function `int main()':
test.cpp:1: error: `printf' undeclared (first use this function)
test.cpp:1: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\Temp>
--- End code ---
So it'll work in C, but not in C++. C++ always requires prototypes/definitions, C just assumes that the parameter types are the types of what was passed and that it returns int if no prototype/definition is given (though GCC will warn about it if -Wall is passed).
However, since this thread was about C (Pelles C doesn't support C++) thomas is more right.
This is one of the things I dislike most about C.
-Wall, never compile C without it ;).
Navigation
[0] Message Index
[*] Previous page
Go to full version