BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Declaration terminated incorrectly

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Chris
Guest





PostPosted: Mon Dec 18, 2006 9:10 am    Post subject: Declaration terminated incorrectly Reply with quote



Hi

I get the following error

[C++ Error] dxUxTheme.hpp(70): E2040 Declaration terminated incorrectly

for this line

static const Shortint DTT_GRAYED = 0x1;

I believe that this is actually caused by a naming conflict with MS's theme
header as if I rename the constant the error goes. I have simply commented
out the consts that lead to the error and all seems to be working correctly
but I wonder what the correct way of handling this really is?

Best regards

Chris F
Back to top
Duane Hebert
Guest





PostPosted: Mon Dec 18, 2006 5:07 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote



"Alan Bellingham" <alanb (AT) episys (DOT) com> wrote in message
news:n1nco2pd3ecnjsqi0tsjssrfpcjj376f4c (AT) 4ax (DOT) com...
Quote:
"Chris" <nospam (AT) nospam (DOT) com> wrote:

I get the following error

[C++ Error] dxUxTheme.hpp(70): E2040 Declaration terminated incorrectly

for this line

static const Shortint DTT_GRAYED = 0x1;

I believe that this is actually caused by a naming conflict with MS's
theme
header as if I rename the constant the error goes. I have simply
commented
out the consts that lead to the error and all seems to be working
correctly
but I wonder what the correct way of handling this really is?

It's likely that DTT_GRAYED is a macro definition - it's all upper-case.
Trying to declare an initialiser with the name of a pre-existing macro
will tent to give you such errors, so it's a good idea never to do it.

How to avoid macro names? It's relatively easy - never use those names
conventionally reserved to macros. You broke that rule here, possibly
because you weren't aware of it.

The rule is - macros are ALL upper-case, nothing else is.

Unhappily, it's frequently broken by Microsoft, who even use all
uppercase for type names.

and all lower case for macros.
Back to top
Alan Bellingham
Guest





PostPosted: Mon Dec 18, 2006 5:14 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote



"Duane Hebert" <spoo (AT) flarn2 (DOT) com> wrote:

Quote:
"Alan Bellingham" <alanb (AT) episys (DOT) com> wrote in message

Unhappily, it's frequently broken by Microsoft, who even use all
uppercase for type names.

and all lower case for macros.

Indeed.

OK, so there are a couple of places where standard C uses lower case
macros - assert() is the most obvious - but you really don't want to see
my undefs.h header file which very carefully undoes all those Microsoft
macros and replaces the relevant functions with overloaded equivalents.

Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel
Back to top
vavan
Guest





PostPosted: Mon Dec 18, 2006 5:25 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote

On Mon, 18 Dec 2006 11:14:09 +0000, Alan Bellingham <alan (AT) lspace (DOT) org>
wrote:

Quote:
macros - assert() is the most obvious - but you really don't want to see
my undefs.h header file which very carefully undoes all those Microsoft

quite the contrary I believe that would be very interesting for those
who suffering from all that ms-macrohell to see your undefs :)

--
Vladimir Ulchenko aka vavan
Back to top
Alan Bellingham
Guest





PostPosted: Mon Dec 18, 2006 5:43 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote

vavan <VavanRemove (AT) ThisSantel (DOT) ru> wrote:

Quote:
quite the contrary I believe that would be very interesting for those
who suffering from all that ms-macrohell to see your undefs Smile

*grin*

I don't want to see it, then!

Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel
Back to top
Chris
Guest





PostPosted: Tue Dec 19, 2006 9:10 am    Post subject: Re: Declaration terminated incorrectly Reply with quote

"Alan Bellingham" <alanb (AT) episys (DOT) com> wrote in message
news:n1nco2pd3ecnjsqi0tsjssrfpcjj376f4c (AT) 4ax (DOT) com...
Quote:

It's likely that DTT_GRAYED is a macro definition - it's all upper-case.
Trying to declare an initialiser with the name of a pre-existing macro
will tent to give you such errors, so it's a good idea never to do it.
snip


Thanks Alan.

As it happens I managed to find some google entries about this and it
appears that perhaps DevExpress (the DxUxTheme.hpp file is from them) should
be using $EXTERNALSYM.

Anyway, apparently wrapping the declarations with #if !defined(_UXTHEME_H_)
cures the problem.

Thanks again.

Chris
Back to top
Roddy Pratt
Guest





PostPosted: Thu Dec 21, 2006 5:23 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote

Alan - Your undefs.h sounds interesting. I've proposed something
similar here for some specific gotchas,

http://qc.borland.com/wc/qcmain.aspx?d=29106


- Roddy
Back to top
Alan Bellingham
Guest





PostPosted: Thu Dec 21, 2006 6:55 pm    Post subject: Re: Declaration terminated incorrectly Reply with quote

"Roddy Pratt" <> wrote:

Quote:
Alan - Your undefs.h sounds interesting. I've proposed something
similar here for some specific gotchas,

http://qc.borland.com/wc/qcmain.aspx?d=29106

The problem I have is that undefs.h is 175,000+ lines in length. (I
could cut it way down by disabling a certain error message.)

Quote:
#if defined(AnsiLowerBuff) // (4499:#define AnsiLowerBuff CharLowerBuffA)
# undef AnsiLowerBuff
#endif AnsiLowerBuff

Then I have another file, redefs.h, that I include, that looks like:

Quote:
inline DWORD AnsiLowerBuff(char * Src, DWORD cchLength) { return CharLowerBuffA(Src, cchLength); }
inline DWORD AnsiLowerBuff(wchar_t* Src, DWORD cchLength) { return CharLowerBuffW(Src, cchLength); }

This one is much shorter, but only includes those functions I personally
have used and bothered to produce inliners for. And actually, I tend to
type the terminating A or W these days.

The problem with the Microsoft way of doing things is that it's targeted
to those using C. The C++ way - using inline forwarding to the relevant
target using overloading - is much less intrusive, but we don't have
proper C++ bindings.

Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.