2

How to make sure, that my code is compatible with every gcc compiler set to the most strict level? Is there any tester tool or do I need to test it manually somehow? Thanks

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
user10099
  • 1,345
  • 2
  • 17
  • 23
  • 1
    There's no way to be completely sure (especially since there are cases of undefined behavior which are almost impossible to detect at compile time), but using `-ansi -pedantic -Wall -Wextra` could be a good start. – Matteo Italia Nov 18 '12 at 14:29
  • thanks. I tried just -Wall at first, there were few warnings that I fixed, but with -ansi, there are around 15 very weird errors/warnings. Couple of times it says that there is unused variable (which is used of course), some parse errors and some other warnings. Should I be worried? I don't see in my code any parse error, or unused variables, so I don't really understand why there are so many errors – user10099 Nov 18 '12 at 15:00
  • 1
    `-ansi` means C89 (shudder), so for example you can't mix declarations and code, you can't use `//` comments, you have "implicit int" and implicit function declarations. `-std=c99 -Wall -Wextra -pedantic-errors` is a good combination, IMO. – Daniel Fischer Nov 18 '12 at 15:05

1 Answers1

0

Every gcc compiler is easy, just use an old one and it will compile for sure with the newer ones.

If you want it to compile with any compiler it's a bit more hard. As suggested you might use the -ansi switch to disable gcc extensions.

LtWorf
  • 7,286
  • 6
  • 31
  • 45