Dec 25, 2014 #1 S shaswat Advanced Member level 4 Joined Jul 2, 2013 Messages 115 Helped 1 Reputation 2 Reaction score 1 Trophy points 18 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?
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?
Dec 25, 2014 #2 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,525 Helped 14,760 Reputation 29,802 Reaction score 14,130 Trophy points 1,393 Location Bochum, Germany Activity points 298,553 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" ?
Dec 25, 2014 #3 S shaswat Advanced Member level 4 Joined Jul 2, 2013 Messages 115 Helped 1 Reputation 2 Reaction score 1 Trophy points 18 Activity points 963 FvM said: 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" ? Click to expand... 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: Dec 25, 2014
FvM said: 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" ? Click to expand... 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.
Dec 25, 2014 #4 Easyrider83 Advanced Member level 5 Joined Oct 11, 2011 Messages 1,608 Helped 374 Reputation 748 Reaction score 363 Trophy points 1,363 Location Tallinn, Estonia Activity points 8,575 Code: #define CUBE(x) (x*x*x) Possible, this what you mean?
Dec 26, 2014 #5 S shaswat Advanced Member level 4 Joined Jul 2, 2013 Messages 115 Helped 1 Reputation 2 Reaction score 1 Trophy points 18 Activity points 963 Easyrider83 said: Code: #define CUBE(x) (x*x*x) Possible, this what you mean? Click to expand... what will have the solution then?
Easyrider83 said: Code: #define CUBE(x) (x*x*x) Possible, this what you mean? Click to expand... what will have the solution then?
Dec 26, 2014 #6 U ud23 Advanced Member level 3 Joined Apr 20, 2011 Messages 926 Helped 185 Reputation 370 Reaction score 180 Trophy points 1,323 Activity points 6,138 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)
Dec 27, 2014 #7 S shaswat Advanced Member level 4 Joined Jul 2, 2013 Messages 115 Helped 1 Reputation 2 Reaction score 1 Trophy points 18 Activity points 963 ud23 said: 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) Click to expand... Such an idiotic point that I missed. Ssshit That was definitely bcoz of my brain break down .
ud23 said: 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) Click to expand... Such an idiotic point that I missed. Ssshit That was definitely bcoz of my brain break down .