macro question

A

abir

Hi,
this is not related to strict c++ , but macro.
I want a statement to be generated like
std::size_t count = sizeof(trace2)/sizeof(coord_t);
for (std::size_t i = 0; i< count; i += 2){
std::cout<<trace2<<" "<<trace2[i+1]<<std::endl;
}

when i write LOAD_TOKEN(2)

so the main problem is to essentially catenate "token" with a token
id.
I am looking at ##, but in between something fails to compile.
thanks
abir
 
T

Tom

Hi,
so the main problem is to essentially catenate "token" with a token
id.
I am looking at ##, but in between something fails to compile.
Usually it works like this:

#define LOAD_TOKEN(n) ....token##n....

where "..." has to be your code, of course.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top