operator or loop problem?

VS tells me this error:
Error 2 error C2143: syntax error : missing ')' before ';'

1
2
3
4
5
6
#define idEM001 5001;
#define idEM121 5121;

int i;
for ( i = idEM001; i < idEM121 ; i++)
{};

In the loop.
warning C4552: '<' : operator has no effect; expected operator with side-effect


1
2
3
int i;
for ( i = idEM01; i <= idEM01 ; i++)
{};


warning C4552: '<=' : operator has no effect; expected operator with side-effect

What is wrong here?
The problem is the semicolon at the end of the #define s.

Better use const: const int idEM001 = 5001;
TO explain what coder777 says: after macro substitution your line looks like:
for ( i = 5001;; i < 5121;; i++)
And as a side-note, your semi-colon on line 6 in the first code snippet and line 3 in the second code snippet is doing sod all. Effectively you've just added an empty statement.
Thanks guys, but the define is in separate file and it did not give error.
I have commented the loop and cannot find it now. Tomorrow I will see.

Is there trick to suppress the warning:
C4114: same type qualifier used more than once
?

Yet one more problem:
extern const int * mapCopyControls[15] = {
IDC_MAP_GROUPBOX,IDC_MAP_TEXTFROM,IDC_TR_MCX1,
IDC_TR_MCY1,IDC_TR_MCSET1,IDC_TR_MCX2,IDC_TR_MCY2,IDC_TR_MCSET2,
IDC_TR_MCCOPY,IDC_MAP_TEXTTO,IDC_TR_MCXT,IDC_TR_MCYT,IDC_TR_MCSETT,IDC_TR_MCPASTE };

Error 3 error C2440: 'initializing' : cannot convert from 'int' to 'const int *'
Last edited on
It looks like IDC_MAP_GROUPBOX, etc. are not pointers.
Ok, solved, thanks. The warnings problem stays.
do not use type qualifier twice. I suppose you have const const somewhere
There are double * but this is not my design. There are these functions in program not designed by me. Not supposed I should change that. I could not make the program working again.
I have changed Options -> Debuging -> Output Window -> All Debug Window, it seems it gives no Warning for now.
There are double *
* is not a type qualifier. Those are const/volatile/mutable/constexpr/static/extern/typedef. If somebody decided to crety a type alias using macro (extremely stupid idea) and did it like this: #define MY_TYPE const int , and then you use it like that: void foo(const MY_TYPE& bar), then you have a problem: after mcro expansion, you will have two const in function declaration

it gives no Warning
Do not supress that warning. Because it should be an error. MS is violating standard alowing to compile this.
Topic archived. No new replies allowed.