pristo said:
it a type mistake i write a new smaple code
file1.h
#define PARAM1 10
#define PARAM2 20
#define PARAM3 30
end of file1.h
file2.h
#define TEST1 PARAM2
end of file2.h
file3.h
#if (TEST1 == PARAM2)
...
#else
...
#endif
end of file3.h
- if i put the same code of file3.h at c file the #if statment will
work fine else its not work
thanks for helping
You still need to show us *exactly* what you're trying to do. I
presume you don't literally have "..." lines in file3.h; what's really
there? You say it doesn't work; what exactly does that mean? What
does it do, and what did you expect it to do?
You're not showing us the actual code that you're compiling, just a
summary of it. The error is somewhere in what you're not showing us.
Don't try to guess what information you think we need.
Here's an example of the level of detail we need:
==================== file1.h ====================
#define PARAM1 10
#define PARAM2 20
#define PARAM3 30
=================================================
==================== file2.h ====================
#define TEST1 PARAM2
=================================================
==================== file3.h ====================
#if (TEST1 == PARAM2)
const char *message = "ok";
#else
const char *message = "error";
#endif
=================================================
==================== main1.c ====================
#include <stdio.h>
#include "file1.h"
#include "file2.h"
#include "file3.h"
int main(void)
{
printf("message = \"%s\"\n", message);
return 0;
}
=================================================
==================== main2.c ====================
#include <stdio.h>
#include "file1.h"
#include "file2.h"
#if (TEST1 == PARAM2)
const char *message = "ok";
#else
const char *message = "error";
#endif
int main(void)
{
printf("message = \"%s\"\n", message);
return 0;
}
=================================================
When I compile "main1.c" and execute the resulting program, the output is
message = "ok"
When I compile "main2.c" and execute the resulting program, the output is
message = "ok"
(identical to the output of main1).
This doesn't exhibit an error; if it did, I'd also specify what output
I expected to see.