0

As I said I want to know if a static C lib compiled with a C standard can work with a program with another C standard (example: C11 static lib with C89 program).

I know compilers don't always produce compatible code between each other, and I suppose that the same compiler will produce compatible code between two standards (tested with GCC, no problem)... But is it a rule that I can assume is true?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 2
    https://stackoverflow.com/q/4489012 – Robert Harvey Dec 05 '21 at 14:53
  • 1
    If the libraries are produced for the same platform — the o/s on the hardware — then it is rare indeed for there to be a problem. On macOS, I occasionally get a warning about some code having been compiled for a different o/s interface than the current one, but that's only a warning. You can basically assume it is true, and be very surprised if you run across a counter-example. – Jonathan Leffler Dec 05 '21 at 15:02
  • Thank you for the answer. So if I resume: std C version is used by compiler only to enable some features and optimization but doesn't affect compatibility between two binary file .. So in theory I can compile in same program a .c with different C version than others ... that it ? – Léo Cardao Dec 05 '21 at 15:10
  • 1
    Your mileage may vary. If you link a library that relied on features such as `threads` or `thread local storage` with a main and libraries from an earlier feature set, you are likely to have problems. More recent feature sets may have implicit dependencies on the C Runtime Library (crt) that are not explicit in the C Library (libc). – mevets Dec 05 '21 at 15:23

0 Answers0