I want to use TRUE and FALSE macros in my custom header file which is intended to be used by different .c files as some common macro definitions file.
The problem I encountered is as follows: Both 3dparty and I define the same macros but those values can differ (TRUE or FALSE can be a pretty simple situation as that is more obvious which values go where).
I want to emphasize that I can`t include that 3party header in my custom code, as that library is not the common thing used in each project. What is more, it seems strange? (or no - but it works though:) ). The solution I see could be also doing some prefixes like CUSTOM_TRUE - but it looks ugly.
Or I shouldn`t bother about it at all and just make it work in any way I choose?
Some case modelling:
main.c
#include "3dparty.h"
#include "b.h"
/* TRUE defined from "custom" header and == 2
- in this case we are good */
int res = cus_is_digit("1");
if (res == TRUE)
{
...
}
/* 3dparty is returning TRUE as 1 but we are checking for 2 */
int res2 = is_something(...);
if (res2 == TRUE)
{
}
...
b.h
#undef TRUE
#define TRUE 2
#endif
OR
#ifndef
#define TRUE 2
#endif
/* This file uses TRUE macro defined with value 2. */
/*Sorry for definition in header */
int cus_is_digit(const char *sdigit)
{
/* some logic here */
return TRUE; /* return 2; */
}
...
3dparty.h
#define TRUE 1
int is_something(...);
...
3dparty.c
#include 3dparty.h
int is_something(...)
{
...
return TRUE; /* return 1; */
}
...