tags:

views:

213

answers:

2

Hello,

I've a curious behavior in a C program. I pass a few arguments to a function with the following signature in a file called foo.c:

foo (char *first, size_t a, size_t b, size_t c, char *last);

Now, when I call this function from another C file that includes foo.h, e.g. with:

foo("first value", 1, 2, 3, "last value");

in foo first, a, b, c are correct but last is always NULL. It does not matter what kind of type I use as the last parameter nor from where I call this function (even directly in main without any previous operations). The files are compiled and linked together in one executable. When I put foo () in the same source file from where it is called everything works.

Does anyone have an idea what might be the reason why when the function is outsourced the last parameter is NULL?

+2  A: 

Without seeing the code, my guess would be that your function declaration (in the header) is out of whack with the definition (in the source file).

anon
A: 

thanks for the quick responses,

litb's hint was correct. In another header file I missed to include size_t was redefined. So basically one source file used a 32bit and another one a 64bit size_t datatype.

(could not post any code because the customer is kind of icky with that)