error C2143
-
I come back for another strange error (for me is strange :) ):
error C2143: syntax error : missing ')' before '{'
And the lin with error is:
TestAndClearDirty(ni); // <-- error C2143: syntax error : missing ')' before '{'
and
TestAndClearDirty
is declared as:#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)where
test_and_clear(ni, Name)
is defined as:#define test_and_clear(ni, flag) \
test_and_clear_bit(NI_##flag, (ni)->state)and
clear_bit
is declared as:#define test_and_clear_bit(bit, var) \
({ \
const BOOL old_state = test_bit(bit, var); \
clear_bit(bit, var); \
old_state; \
})How to get rid of this error ?
-
I come back for another strange error (for me is strange :) ):
error C2143: syntax error : missing ')' before '{'
And the lin with error is:
TestAndClearDirty(ni); // <-- error C2143: syntax error : missing ')' before '{'
and
TestAndClearDirty
is declared as:#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)where
test_and_clear(ni, Name)
is defined as:#define test_and_clear(ni, flag) \
test_and_clear_bit(NI_##flag, (ni)->state)and
clear_bit
is declared as:#define test_and_clear_bit(bit, var) \
({ \
const BOOL old_state = test_bit(bit, var); \
clear_bit(bit, var); \
old_state; \
})How to get rid of this error ?
_Flaviu wrote:
How to get rid of this error ?
Anytime you are having preprocessor troubles, the only solution is to send the output of the preprocessor to a text file using the
/P
compiler switch. Only then will you be able to see what exactly is being sent through the compiler. See here for more."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
-
Yes, but I don't know if I can, because from step
TestAndClearDirty(ni);
totest_and_clear(ni, Name)
, the second paramter is missing (see the first post). Moreover, atstep test_and_clear_bit(NI_##flag, (ni)->state)
what is the first parameter ? -
That is exactly the problem. We do not have that information and you are not providing it.
Believe me, I haven't extra information, for instance, at step
test_and_clear(ni, Name)
, when I try to go to definition ofName
, VS editor goes nowhere, searched globally in the whole project, found nothing, and searched in the entire project folder with the external file seeker, found no defintion of thisName
parameter ... -
Believe me, I haven't extra information, for instance, at step
test_and_clear(ni, Name)
, when I try to go to definition ofName
, VS editor goes nowhere, searched globally in the whole project, found nothing, and searched in the entire project folder with the external file seeker, found no defintion of thisName
parameter ...In the following macro
Name
refers to something outside of the definition:#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)But if
Name
does not exist in that source module, or is not externalised in a linked module it will never work. My suspicion is that this macro is wrong andName
should be one of the formal parameters, and refer to one of the flags in the ni struct. Something like:#define TestAndClearDirty(ni, Name) \
test_and_clear(ni, Name)And it would be called by
TestAndClearDirty(ni, some_falg_name);
But I am working completely in the dark and making (probably wild) guesses. I can only suggest that you go back to the place or person that this code comes from for assistance.
-
In the following macro
Name
refers to something outside of the definition:#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)But if
Name
does not exist in that source module, or is not externalised in a linked module it will never work. My suspicion is that this macro is wrong andName
should be one of the formal parameters, and refer to one of the flags in the ni struct. Something like:#define TestAndClearDirty(ni, Name) \
test_and_clear(ni, Name)And it would be called by
TestAndClearDirty(ni, some_falg_name);
But I am working completely in the dark and making (probably wild) guesses. I can only suggest that you go back to the place or person that this code comes from for assistance.
I have discovered something: if I write:
TestAndClearDirty(ni);
everything is ok. But if I write:
BOOL b = TestAndClearDirty(ni); // <-- errors
I get errors:
error C2552: 'b' : non-aggregates cannot be initialized with initializer list
error C2143: syntax error : missing '}' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2065: 'old_state' : undeclared identifierSee first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function,
TestAndClearDirty
, is used inside some if condition ... -
I come back for another strange error (for me is strange :) ):
error C2143: syntax error : missing ')' before '{'
And the lin with error is:
TestAndClearDirty(ni); // <-- error C2143: syntax error : missing ')' before '{'
and
TestAndClearDirty
is declared as:#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)where
test_and_clear(ni, Name)
is defined as:#define test_and_clear(ni, flag) \
test_and_clear_bit(NI_##flag, (ni)->state)and
clear_bit
is declared as:#define test_and_clear_bit(bit, var) \
({ \
const BOOL old_state = test_bit(bit, var); \
clear_bit(bit, var); \
old_state; \
})How to get rid of this error ?
When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
I have discovered something: if I write:
TestAndClearDirty(ni);
everything is ok. But if I write:
BOOL b = TestAndClearDirty(ni); // <-- errors
I get errors:
error C2552: 'b' : non-aggregates cannot be initialized with initializer list
error C2143: syntax error : missing '}' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2065: 'old_state' : undeclared identifierSee first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function,
TestAndClearDirty
, is used inside some if condition ... -
When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
I have put that option on property page settings and show me no more details: The error occur in some inode.cpp file (ex C file), and those macros are some support.h file. So, when I compiled with /P option, I got only inode.i file, where I have a line:
#line 1 "d:\\project\\.......\\inode.cpp"
that is all. And support.i doesn't generated, due to error:
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...The problem is that macro TestAndClearDirty(ni); is
-
When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
I have put that option on property page settings and show me no more details: The error occur in inode.cpp file (former inode.c file), and those macros are in **support.**h file. So, when I compiled with /P option, I got only inode.i file, where I have a line:
#line 1 "d:\\project\\.......\\inode.cpp"
that is all. And support.i doesn't generated, due to error:
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
...The problem is the code is trying to use TestAndClearDirty(ni); for returning BOOL value, and I don't think that macro is written to return a BOOL value ... I guess from here is coming these errors ...
-
I have discovered something: if I write:
TestAndClearDirty(ni);
everything is ok. But if I write:
BOOL b = TestAndClearDirty(ni); // <-- errors
I get errors:
error C2552: 'b' : non-aggregates cannot be initialized with initializer list
error C2143: syntax error : missing '}' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2065: 'old_state' : undeclared identifierSee first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function,
TestAndClearDirty
, is used inside some if condition ...test_and_clear is a macro you can't use it as a function, macros don't return things without hijinx :-) GCC has a thing called a statement expression Using the GNU Compiler Collection (GCC): Statement Exprs[^] However I strong suggestly you don't do it just create a proper function (that is after all what you are trying to write) and inline it if speed is an issue.
In vino veritas