Created at:
Modified at:
gcc notes
General tips
Passing #define at calling time
If you want to pass defines but don't want to edit the sources to include the
#define
's, just call gcc with the -D option:
The following is equivalent to put #define
Linux in the source::
$ gcc -DLinux ...
The following is equivalent to put #define OS Linux in the source::
$ gcc -DOS=Linux
Compiling a single object file (without linking)
Just call gcc with the -c
option.
Only pre-processing the source code -----------------------------------
Just call gcc with the -E
option.
Troubleshooting
Error specifier-qualifier-list before...
If you get an error like::
In file included from nettest.c:5:
proto-hiware.h:19: error: expected specifier-qualifier-list before 'uint16_t'
see if you have <sys/types.h>
(NetBSD) included in the header. If not, the
compiler will not recognize uint16_t
, which is not part of the language
itself.
Error expected class-name before '(' token
For errors like the following::
tlmgui_dievent.h:23: error: expected class-name before '(' token
See if, in this line, there is a destructor. If so, check if its name is the same of the class (a typo when typing the destructor name can generate this problem).
Error multiple definition of
If you are trying to link an application against a static library and you get an error like "multiple definition of" for a global variable that both the library and the application use, it is a good idea to use it in only one place, or see link below for other possible solutions.
multiple definition error - global variable header
Error expected '=', ',', ';', 'asm' or '__attribute__' before
See if the item before the word that before
refers to can be resolved. For
example::
bool sectint(double x, double y, struct secteur *sect, int nseg);
The compiler couldn't find bool. So I discovered that bool is not declared for C89. The line above produced the following error::
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sectint
Error "integer constant is too large for "long" type"
By default, pre-compiler puts integer macros in "long" (32 bits) regions of memory. If 32 bits are not enough, we need to tell the compiler we need to tell it to allocate the value in a long long, appending "LL" after the constant value::
#define MAX_DIR_SIZE 6442450944LL // 6 GB in bytes
This page
__ helped me.
Problems with 64bit integer constants | C++ | Coding Forums
Error "error: function definition does not declare parameters"
(2010-01-07)
If you get this error, you maybe used :
instead of ::
in a function
declaration, like::
void Ball:Kick
Instead of::
void Ball::Kick
C++: function definition does not declare parameters
Error "expected type-specifier before"
(2010-10-04)
This error can be caused by differente reasons, one of them is that you
probably wrote :
when g++
expects ::
(namespace separator). Check
your code again.
Error "two or more data types in declaration specifiers"
(2014-11-15)
Did you forget to add a semicolon after the struct declaration just before the error line is occurring?