05 Dec, 2008, Lobotomy wrote in the 1st comment:
Votes: 0
Something I wasn't entirely aware of before taking to moving to a new server is that apparently some functions of C change based on which machine you compile your code on. Strerror_r is apparently one of them, as according to this page the function will return an integer if compiled on a machine where _XOPEN_SOURCE of 600 or higher is defined, or it will return a char string pointer if that isn't defined or defined at a lower value. Considering that the function I wrote that uses strerror_r previously worked on the integer return version, I can only assume that my current host does not have said value defined as the function is now complaining about being broken due to character pointer to integer problems.

So I'm curious. How often do these sort of C compatibility issues come up? Ideally, I want the codebase I'm writing to work with as little machine-based modification for a user as possible (where linux machines are concerned, anyways). I just wasn't expecting that I'd have to start writing multiple/variant sections of code and functions to suit the environment of a particular machine; i.e, have macro sections set up to check for particular values and compile one version or another depending on the result.

Additionally, I'm wondering if anyone has a thought for other methods by which this could be resolved; i.e, force the compiler to provide the integer-return version of strerror_r. I figured that defining _XOPEN_SOURCE at 600 would do the trick (via -D_XOPEN_SOURCE=600 in the makefile), and while that does switch the function to the correct type, it just about breaks everything else.

Edit: I should note that the problem with the function using strerror_r itself is currently resolved, due to using a macro section that checks against the existence and value of _XOPEN_SOURCE, but I'm still curious to hear other information and solutions and whatnot on the topics above.
05 Dec, 2008, Zeno wrote in the 2nd comment:
Votes: 0
Quote
So I'm curious. How often do these sort of C compatibility issues come up?

The only time I've had issues is moving between 32bit and 64bit servers. That's it.
05 Dec, 2008, Fizban wrote in the 3rd comment:
Votes: 0
Zeno said:
Quote
So I'm curious. How often do these sort of C compatibility issues come up?

The only time I've had issues is moving between 32bit and 64bit servers. That's it.


That's the only time for me as well, specifically with things like size_t and time_t.
05 Dec, 2008, Lobotomy wrote in the 4th comment:
Votes: 0
Fizban said:
Zeno said:
Quote
So I'm curious. How often do these sort of C compatibility issues come up?

The only time I've had issues is moving between 32bit and 64bit servers. That's it.


That's the only time for me as well, specifically with things like size_t and time_t.

I see. Well, I suppose this was just more or less a fluke or rarity compared to the norm then.
05 Dec, 2008, David Haley wrote in the 5th comment:
Votes: 0
I've run into compatibility issues with default signing of characters, 32 vs 64 bits, and occasional differences in availability of functions based on the standard libraries present. I've never run into the one you mentioned, though.
0.0/5