S
Stephen
Is there a standard way to remove the warning that a C compiler might
produce from the statement:
if (a = b) {}
I don't want to do:
if ((a = b) != 0) {}
Because my "a = b" is actually contained in a macro that might be used
as a statement or as an expression within (for example) an "if"
statement.
If it makes any difference, here's exactly what I'm trying to do. In
order to get around a limitation of a particular C compiler that will
not allow p++ (or any other pointer arithmetic) to work correctly across
64KB boundaries, I have come up with a few macros, one of which is:
#define FARPTR_INC(p) p=(void far *)(((ULONG)(p))+sizeof(*(p)))
Now I can do:
UBYTE far *pb;
UWORD far *pw;
ULONG far *pl;
FARPTR_INC(pb); // Replacement for: pb++; (adds 1 to address)
FARPTR_INC(pw); // Replacement for: pw++; (adds 2 to address)
FARPTR_INC(pl); // Replacement for: pl++; (adds 4 to address)
I can also do:
func(FARPTR_INC(p)); // Replacement for: func(p++);
But if I do:
if (FARPTR_INC(p)) {}
Then I get a warning since the compiler is justifiably taking the view
that I might have missed an equals sign and accidentally turned an
equality comparison into an assignment.
[Please excuse the C++ commenting style in my C code. I know you're all
C purists in c.l.c, and rightly so, but I choose to use C++ comments in
my C code because every C compiler I use (or probably ever will use now)
handles it ;-)
.... oh, and stuff like UBYTE is "#define UBYTE unsigned char" etc.]
produce from the statement:
if (a = b) {}
I don't want to do:
if ((a = b) != 0) {}
Because my "a = b" is actually contained in a macro that might be used
as a statement or as an expression within (for example) an "if"
statement.
If it makes any difference, here's exactly what I'm trying to do. In
order to get around a limitation of a particular C compiler that will
not allow p++ (or any other pointer arithmetic) to work correctly across
64KB boundaries, I have come up with a few macros, one of which is:
#define FARPTR_INC(p) p=(void far *)(((ULONG)(p))+sizeof(*(p)))
Now I can do:
UBYTE far *pb;
UWORD far *pw;
ULONG far *pl;
FARPTR_INC(pb); // Replacement for: pb++; (adds 1 to address)
FARPTR_INC(pw); // Replacement for: pw++; (adds 2 to address)
FARPTR_INC(pl); // Replacement for: pl++; (adds 4 to address)
I can also do:
func(FARPTR_INC(p)); // Replacement for: func(p++);
But if I do:
if (FARPTR_INC(p)) {}
Then I get a warning since the compiler is justifiably taking the view
that I might have missed an equals sign and accidentally turned an
equality comparison into an assignment.
[Please excuse the C++ commenting style in my C code. I know you're all
C purists in c.l.c, and rightly so, but I choose to use C++ comments in
my C code because every C compiler I use (or probably ever will use now)
handles it ;-)
.... oh, and stuff like UBYTE is "#define UBYTE unsigned char" etc.]