Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Preprocessor error in C

Status
Not open for further replies.

shaswat

Advanced Member level 4
Full Member level 1
Joined
Jul 2, 2013
Messages
115
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Visit site
Activity points
963
I tried to run a simple preprocessor code on my code-block 13.12 IDE. But it shows an error
Code:
error: request for member 'b' in something not a structure or union|

Here is the piece of code:

Code:
#define CUBE(x) (x.x.x)

main()
{
    int  a,  b=3 ;
    a =  CUBE(b++);
    printf (  "\n%d  %d",  a,  b  )  ;
}

Even I am not using any structure and union in my code...

Any help?
 

Simple solution. As b isn't a structure, don't apply structure syntax (x.x.x) to it...

What do you want to achieve with "x.x.x" ?
 
Simple solution. As b isn't a structure, don't apply structure syntax (x.x.x) to it...

What do you want to achieve with "x.x.x" ?

Nothing much as I want to just brush up my preprocessor fundamentals, saw that piece of code and I was expecting some output rather than an "ERROR".

What would be the solution then? I think that this type of error I never got when executed on TURBO C compiler.
 
Last edited:

I guess you want to define cube function with #define macro so


Code C - [expand]
1
#define CUBE(int x)   x*x*x



as answered earlier you are using .(dot) for multiplication insted of *(star)
 
I guess you want to define cube function with #define macro so


Code C - [expand]
1
#define CUBE(int x)   x*x*x



as answered earlier you are using .(dot) for multiplication insted of *(star)
Such an idiotic point that I missed.

Ssshit That was definitely bcoz of my brain break down .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top