Reputation: 58
I am compiling legacy code using gcc compiler 4.8.5 on RHEL7. All C and C++ files have "-unsigned" as one of the default flags for both gcc and g++ compilation. The compiler accepts this option and compiles successfully. However, I cannot find any documentation of this option anywhere either in gcc manual or online. Does anyone know what this option is? I have to port the code and am confused whether this compiler option needs to be ported or not.
Upvotes: 2
Views: 264
Reputation: 263647
I suspect it was just a mistake in the Makefile, or whatever is used to compile the code.
gcc does not support a -unsigned
option. However, it does pass options to the linker, and GNU ld has a -u
option:
'-u SYMBOL'
'--undefined=SYMBOL'
Force SYMBOL to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries. '-u' may be repeated with different option arguments to enter additional undefined symbols. This option is equivalent to the 'EXTERN' linker script command.
The space between -u
and the symbol name is optional.
So the intent might have been to do something with unsigned types, but the effect, at least with modern versions of gcc, is to enter nsigned
in the output file as an undefined symbol.
This seems to have no effect in the quick test I did (compiling and running a small "hello, world" program). The program runs correctly, and the output of nm hello
includes:
U nsigned
With an older version of gcc (2.95.2) on a different system, I get a fatal link-time error about the undefined symbol.
Upvotes: 4
Reputation: 385405
I suspect the intention is for the program to be compiled with -funsigned-char
. I don't know whether this instead used to be -unsigned
, back in dinosaur times, and perhaps GCC actually still heeds that spelling; there's no way to know from the manual because, if it does, it's an undocumented feature.
I'd ask the original author for the intention here, since they didn't see fit to document.
Upvotes: 0