Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > #define errors

Reply
Thread Tools

#define errors

 
 
mohan
Guest
Posts: n/a
 
      01-17-2006
Hi All.

I have error message

#include <stdio.h>

#define NAV_FORMAT_VERSION 10

#define OC_LM_ANNOT 1

#define OC_LM_SHAPE 0

#define OC_EXIST_MASK OC_LM_ANNOT | \

#if NAV_FORMAT_VERSION == 10

OC_LM_SHAPE

#endif

int main()

{

if ( OC_EXIST_MASK)

printf( " Defined");

else

printf( " Not defined ");

return 0;

}



Kindly let me know my mistake....



Mohan


 
Reply With Quote
 
 
 
 
Lucien Kennedy-Lamb
Guest
Posts: n/a
 
      01-17-2006
You don't mention what the error is but I suspect it's an unexpected
#endif.

A trailing \ on a #define has a special meaning and includes the next
line as part of the #define. This means the following #if ... line
doesn't have any effect.

It still won't compile - what was your intention here?

Lucien Kennedy-Lamb

 
Reply With Quote
 
 
 
 
mohan
Guest
Posts: n/a
 
      01-17-2006
error message is as follows

--------------------------------------------

"macro.c", line 8: syntax error before or at: |

"macro.c", line 9: #if-less #endif

"macro.c", line 14: invalid source character: '#'

"macro.c", line 14: syntax error before or at: if

cc: acomp failed for macro.c



-------------------------------------------------------------------

"Lucien Kennedy-Lamb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> You don't mention what the error is but I suspect it's an unexpected
> #endif.
>
> A trailing \ on a #define has a special meaning and includes the next
> line as part of the #define. This means the following #if ... line
> doesn't have any effect.
>
> It still won't compile - what was your intention here?
>
> Lucien Kennedy-Lamb
>



 
Reply With Quote
 
mohan
Guest
Posts: n/a
 
      01-17-2006
i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
defined


"Lucien Kennedy-Lamb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> You don't mention what the error is but I suspect it's an unexpected
> #endif.
>
> A trailing \ on a #define has a special meaning and includes the next
> line as part of the #define. This means the following #if ... line
> doesn't have any effect.
>
> It still won't compile - what was your intention here?
>
> Lucien Kennedy-Lamb
>



 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      01-17-2006
mohan wrote:
> i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
> defined


I'm fairly sure you can't put an #if in the right-hand side of a #define.

- Logan
 
Reply With Quote
 
Lucien Kennedy-Lamb
Guest
Posts: n/a
 
      01-17-2006

Logan Shaw wrote:
> mohan wrote:
> > i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
> > defined

>
> I'm fairly sure you can't put an #if in the right-hand side of a #define.
>
> - Logan


Your right Logan. All preprocessor directives must start on their own
line and can't be constructed by other preprocessor directives.

The preprocessor won't recursively parse the source file.

I think your solution is:

#if NAV_FORMAT_VERSION == 10
#define OC_EXIST_MASK (OC_LM_ANNOT | OC_LM_SHAPE)
#else
#define OC_EXIST_MASK OC_LM_ANNOT
#endif

Lucien Kennedy-Lamb

 
Reply With Quote
 
Jaspreet
Guest
Posts: n/a
 
      01-17-2006
mohan wrote:
> i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
> defined
>
>
> "Lucien Kennedy-Lamb" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > You don't mention what the error is but I suspect it's an unexpected
> > #endif.
> >
> > A trailing \ on a #define has a special meaning and includes the next
> > line as part of the #define. This means the following #if ... line
> > doesn't have any effect.
> >
> > It still won't compile - what was your intention here?
> >
> > Lucien Kennedy-Lamb
> >


#if NAV_FORMAT_VERSION == 10
#define OC_LM_SHAPE 0
#endif

OR

You could also use the #ifdef macro.

However, I still could not understand what you meant by the statement:
#define OC_EXIST_MASK OC_LM_ANNOT | \

With what do you want to OR the OC_LM_ANNOT flag ?

 
Reply With Quote
 
Jaspreet
Guest
Posts: n/a
 
      01-17-2006
mohan wrote:
> i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
> defined
>
>
> "Lucien Kennedy-Lamb" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > You don't mention what the error is but I suspect it's an unexpected
> > #endif.
> >
> > A trailing \ on a #define has a special meaning and includes the next
> > line as part of the #define. This means the following #if ... line
> > doesn't have any effect.
> >
> > It still won't compile - what was your intention here?
> >
> > Lucien Kennedy-Lamb
> >


#if NAV_FORMAT_VERSION == 10
#define OC_LM_SHAPE 0
#endif

Or you also use #ifdef macro.

However i still could not understand what you meant by:
#define OC_EXIST_MASK OC_LM_ANNOT | \

With what do you want to OR the OC_LM_ANNOT flag to ?

 
Reply With Quote
 
Jaspreet
Guest
Posts: n/a
 
      01-17-2006
mohan wrote:
> i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
> defined
>
>
> "Lucien Kennedy-Lamb" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > You don't mention what the error is but I suspect it's an unexpected
> > #endif.
> >
> > A trailing \ on a #define has a special meaning and includes the next
> > line as part of the #define. This means the following #if ... line
> > doesn't have any effect.
> >
> > It still won't compile - what was your intention here?
> >
> > Lucien Kennedy-Lamb
> >


#if NAV_FORMAT_VERSION == 10
#define OC_LM_SHAPE 0
#endif

Or you also use #ifdef macro.

However i still could not understand what you meant by:
#define OC_EXIST_MASK OC_LM_ANNOT | \

With what do you want to OR the OC_LM_ANNOT flag to ?

 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      01-17-2006
On Tue, 17 Jan 2006 10:47:45 +0530, in comp.lang.c , "mohan"
<(E-Mail Removed)> wrote:

>i wanted to include symbol OC_LM_SHAPE only when NAV_FORMAT_VERSION is
>defined


#if defined (NAV_FORMAT_VERSION)
#define OC_LM_SHAPE
#endif

Also...

>#define OC_EXIST_MASK OC_LM_ANNOT | \


what are the trailing |\ doing there?

>#if NAV_FORMAT_VERSION == 10
>OC_LM_SHAPE
>#endif


Remember that macros are literally replaced in the code by their
value. So this translates into

#if 10 == 10
0
#endif

which is a syntax error


Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net- 0 Build Errors, but I am prompted that there were build errors? Lance Wynn ASP .Net 1 02-03-2008 12:20 AM
Out-of-memory errors and caching errors. George1776 ASP .Net 2 09-14-2006 03:34 PM
Obsolete Errors and Deprecated Errors using Dotnet Framework 2.0 SenthilVel ASP .Net 0 06-07-2006 11:48 AM
Internet Explorer causing errors/ slow internet speed and Outlook express errors Jeanne Medley Computer Support 2 02-11-2004 11:44 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments