473,324 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Macro assignmnet to a variable


I have two macros in a.h file

like #define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01
when I am including this file
in main program i.e main.c

#include " a.h"

and trying to assign it to a variable

int type = DEVPKTTYPE;

I am getting the compiler error saying parse error before line number
specifying this line (int type = DEVPKTTYPE)

but when I am doing the #defines itself in main.c file

like
#define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01

main()
{
int type = DEVPKTTYPE;
}

I am not facing the parse error. what was the problem while I included
the a.h file. please help me.

Nov 15 '05 #1
3 1619
"saleem" <su**************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

I have two macros in a.h file

like #define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01
when I am including this file
in main program i.e main.c

#include " a.h"

and trying to assign it to a variable

int type = DEVPKTTYPE;

I am getting the compiler error saying parse error before line number
specifying this line (int type = DEVPKTTYPE)
What is *before* this line? Maybe there's an error somewhere in the a.h file
(in the middile or in the end), which happens to be processed exactly before
the line you showed us.
but when I am doing the #defines itself in main.c file

like
#define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01

main()
{
int type = DEVPKTTYPE;
}

I am not facing the parse error. what was the problem while I included
the a.h file. please help me.


This code is either incomplete or to some degree incorrect (missing the int
return type in definition of main()). But other than that there's no
problem.

Alex
Nov 15 '05 #2

Alexei A. Frounze wrote:
main()
...snipped rest of the quote ... This code is either incomplete or to some degree incorrect (missing the int
return type in definition of main()). But other than that there's no
problem.


Not incorrect, technically, but old style C which is not recommended.

Nov 15 '05 #3

"saleem" <su**************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

I have two macros in a.h file

like #define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01
when I am including this file
in main program i.e main.c

#include " a.h"
Did you really have a space in your literal?
Perhaps that's the trouble.

and trying to assign it to a variable

int type = DEVPKTTYPE;

I am getting the compiler error saying parse error before line number
specifying this line (int type = DEVPKTTYPE)

but when I am doing the #defines itself in main.c file

like
#define DEVPKTTYPE 0x00
#define ETHPKTTYPE 0x01

main()
{
int type = DEVPKTTYPE;
}

I am not facing the parse error. what was the problem while I included
the a.h file. please help me.


Well, logically (if you're presenting accurate information),
there's something wrong in your header, or with the directive
which includes it.

-Mike
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
8
by: lasek | last post by:
Hi...in some posts i've read...something about using macro rather then function...but difference ??. Best regards....
5
by: agsupriya86 | last post by:
Hello! i wanna know about the illfamos null pointer assignmnet error..when can we face such an error and how do we debug it??
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.