|
-
January 12th, 2005, 12:41 PM
#1
compiles in v6, error C2143 in .NET
The following code compiles in c++ v6, but produces error C1243 in .NET 2003 :-
typedef __declspec(dllexport) struct flucsLuminaireRecord
{ <<<<<<< error here <<<<<<<<<
char ID[LUMINAIRENAME];
char categ[CATEGORY];
} FlucsLuminaireRecord;
error C2143: syntax error : missing ';' before '<class-head>'
Anyone know why?
-
January 12th, 2005, 01:00 PM
#2
Re: compiles in v6, error C2143 in .NET
What about this:
Code:
__declspec(dllexport) typedef struct flucsLuminaireRecord
{
char ID[LUMINAIRENAME];
char categ[CATEGORY];
} FlucsLuminaireRecord;
-
January 12th, 2005, 01:11 PM
#3
Re: compiles in v6, error C2143 in .NET
 Originally Posted by martin_craigen
The following code compiles in c++ v6,
No it doesn't. The code you posted as is does not compile in VC 6.0:
Code:
typedef __declspec(dllexport) struct flucsLuminaireRecord
{
char ID[LUMINAIRENAME];
char categ[CATEGORY];
} FlucsLuminaireRecord;
Compiling...
test.cpp
F:\test.cpp(3) : error C2065: 'LUMINAIRENAME' : undeclared identifier
F:\test.cpp(3) : error C2057: expected constant expression
F:\test.cpp(3) : warning C4200: nonstandard extension used : zero-sized array in struct/union
F:\test.cpp(4) : error C2065: 'CATEGORY' : undeclared identifier
F:\test.cpp(4) : error C2057: expected constant expression
F:\test.cpp(4) : error C2229: struct 'flucsLuminaireRecord' has an illegal zero-sized array
F:\test.cpp(4) : warning C4200: nonstandard extension used : zero-sized array in struct/union
Error executing cl.exe.
test.obj - 5 error(s), 2 warning(s)
Please post your entire code. Compiler errors are hard to duplicate if you leave it to us to fill in the blanks.
Regards,
Paul McKenzie
-
January 12th, 2005, 01:33 PM
#4
Re: compiles in v6, error C2143 in .NET
Of course it doesn't, because you are missing the declarations of LUMINAIRENAME and CATEGORY. If have tried it in VC++ .NET 2k and it compiles fine (with declaring the two identifiers as macros).
-
January 12th, 2005, 01:44 PM
#5
Re: compiles in v6, error C2143 in .NET
 Originally Posted by NoHero
Of course it doesn't, because you are missing the declarations of LUMINAIRENAME and CATEGORY. If have tried it in VC++ .NET 2k and it compiles fine (with declaring the two identifiers as macros).
That is the job of the original poster to put those declarations in their message, so that duplication of the compiler error is done without anyone having to add or remove lines of code.
By leaving things out, I don't know if this is what is being compiled. Then we must put code in to try and attempt to duplicate the error. By us putting code in, this will skew the results of what the poster is attempting to compile and what someone here has cobbled together. If it compiles fine after placing those two identifiers, then this makes my point. Is this the code that the OP compiling, or is something missing from their original message because they made a typo, they're too hasty and thrown anything together that looks like code, etc.?
Compiler errors should always be accompanied by the actual code that is being compiled (and I wish this was in the posting FAQ).
Regards,
Paul McKenzie
Last edited by Paul McKenzie; January 12th, 2005 at 01:48 PM.
-
January 12th, 2005, 01:48 PM
#6
Re: compiles in v6, error C2143 in .NET
Of course Paul, you are right. I just wanted to point out, that the syntax of the __declspec() is correct. So he should take a look at the code above. Because I think he is missing a paranthesis or a semicolon after the previous line of code.
-
January 12th, 2005, 01:52 PM
#7
Re: compiles in v6, error C2143 in .NET
 Originally Posted by NoHero
Of course Paul, you are right. I just wanted to point out, that the syntax of the __declspec() is correct. So he should take a look at the code above. Because I think he is missing a paranthesis or a semicolon after the previous line of code.
Then this is weird why it would compile for VC 6.0 as the OP stated, since those types of errors (missing a semicolon, etc.) are usually general C++ errors that are picked up by practically every C++ compiler.
Regards,
Paul McKenzie
-
January 12th, 2005, 02:04 PM
#8
Re: compiles in v6, error C2143 in .NET
 Originally Posted by Paul McKenzie
Then this is weird why it would compile for VC 6.0 as the OP stated, since those types of errors (missing a semicolon, etc.) are usually general C++ errors that are picked up by practically every C++ compiler.
Regards,
Paul McKenzie
It might be a missing semicolon - I don't know of course, because I haven't viewed the code yet - but a missing closing paranthesis is more likely.
-
January 12th, 2005, 03:38 PM
#9
Re: compiles in v6, error C2143 in .NET
 Originally Posted by martin_craigen
Anyone know why?
-
January 13th, 2005, 04:43 AM
#10
Re: compiles in v6, error C2143 in .NET
OK everyone, thanks for taking the time to help.
And it did help, because the comments about posting the whole code prompted me to study the code more closely, and ... I found the problem.
Before posting, I had tried to simplify the post by substituting the macro used to define dllimport/export. It had not dawned on me to check if this was the problem, because the macro is used extensively in the code.
The original code therefore looked more like
typedef CLASS_DECL_FLXDB struct flucsLuminaireRecord
{
char ID[LUMINAIRENAME];
char categ[CATEGORY];
} FlucsLuminaireRecord;
and CLASS_DECL_FLXDB was set up in another header file as follows :-
#ifdef FLXDB_IMPL
#define CLASS_DECL_FLXDB __declspec(dllexport)
#else
#define CLASS_DECL_FLXDB __declspec(dllimport)
#endif
However, in the code I was trying to compile, this second header file had been REMOVED, so the macro was undefined.
Apologies to everyone who wasted their time on this. At least I have learned something from it, and that is to double-check my question and ensure it is valid before asking for help from busy people.
-
January 13th, 2005, 05:22 AM
#11
Re: compiles in v6, error C2143 in .NET
 Originally Posted by martin_craigen
Apologies to everyone who wasted their time on this. At least I have learned something from it, and that is to double-check my question and ensure it is valid before asking for help from busy people.
Don't worry....everybody here is always free to answer a question or not....nevertheless, I agree that before posting one should take a the known paths to find the error...
Have fun with the forums...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|