Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-30 Thread Bob Paddock
> You can't get very meaningful errors here - I have not found any way to get > a user-defined error message in conjunction with static asserts. I added ##_##message, to NAME2_ and updated everything else as needed, so now I get static_assert( 1 == 2, One_Not_Equal_To_Two ); that looks like: asser

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-30 Thread David Brown
On 30/08/2011 14:03, Bob Paddock wrote: Refinements of the concept left as an exercise for the reader. Regards, Does that mean I am not allowed to post my refinements? No. Please post. Extra points for using __FILE__ __FUNCITON__ and __LINE__ to give meaningful error message. The error

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-30 Thread Bob Paddock
>> Refinements of the concept left as an exercise for the reader. Regards, >> > > Does that mean I am not allowed to post my refinements? No. Please post. Extra points for using __FILE__ __FUNCITON__ and __LINE__ to give meaningful error message. Digging out my old issue of Embedded Systems on

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-30 Thread David Brown
On 29/08/2011 22:03, Dave Hansen wrote: > From: graceindustr...@gmail.com [...] > So that explains the difference. Seems like there could be a better > error message for this case, 'don't use enum here', alas "The > preprocessor does not know anything about types in the language"... Here's

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-29 Thread Dave Hansen
> From: graceindustr...@gmail.com [...] > So that explains the difference. Seems like there could be a better > error message for this case, 'don't use enum here', alas "The > preprocessor does not know anything about types in the language"... Here's a cute/ugly little macro that might help yo

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-29 Thread Bob Paddock
On Mon, Aug 29, 2011 at 3:15 PM, Wim Lewis wrote: > On Mon, 29 Aug 2011, Weddington, Eric wrote: >> >> For the preprocessor purposes, I would bet that somehow "last" evaluates >> to 0, so of course the condition will always be true. >   "[6] Identifiers that are not macros, which are all consider

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-29 Thread Wim Lewis
On Mon, 29 Aug 2011, Weddington, Eric wrote: For the preprocessor purposes, I would bet that somehow "last" evaluates to 0, so of course the condition will always be true. Yes, I think this is part of the language standard (for better or worse). I don't have a standard cite but it's described

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-29 Thread Weddington, Eric
-gcc-list-bounces+eric.weddington=atmel@nongnu.org] On > Behalf Of Bob Paddock > Sent: Monday, August 29, 2011 12:37 PM > To: AVR-GCC > Subject: [avr-gcc-list] Can enumerator values be used in a #if > preprocessordirective? > > I have the following file test.c: > > #define MAX (