|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello everyone,
The compile error of the following code is, foo.cpp(7) : error C2146: syntax error : missing ';' before identifier '_' foo.cpp(7) : error C2065: '_' : undeclared identifier foo.cpp(7) : error C2143: syntax error : missing ';' before 'string' I do not know why there is errors. I think in MERGE macro, the value of parameter a is hello and the value of parameter b is world in my case, and I defined hello_world to "H E L L O", it should be fine... Any ideas? Code:
#define MERGE(a,b) a ## _ ## b
#define hello_world "H E L L O"
int foo()
{
char* p0;
p0 = MERGE("hello", "world");
return 0;
}
thanks in advance, George |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
George2 wrote:
> Hello everyone, > > > The compile error of the following code is, > > foo.cpp(7) : error C2146: syntax error : missing ';' before identifier > '_' > foo.cpp(7) : error C2065: '_' : undeclared identifier > foo.cpp(7) : error C2143: syntax error : missing ';' before 'string' > > I do not know why there is errors. I think in MERGE macro, the value > of parameter a is hello and the value of parameter b is world in my > case, and I defined hello_world to "H E L L O", it should be fine... > No, a is "hello" and b is "world" so your macro produces "hello"_"world". -- Ian Collins. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 26, 2:10 pm, George2 <george4acade...@yahoo.com> wrote:
> Hello everyone, > > The compile error of the following code is, > > foo.cpp(7) : error C2146: syntax error : missing ';' before identifier > '_' > foo.cpp(7) : error C2065: '_' : undeclared identifier > foo.cpp(7) : error C2143: syntax error : missing ';' before 'string' > > I do not know why there is errors. I think in MERGE macro, the value > of parameter a is hello and the value of parameter b is world in my > case, and I defined hello_world to "H E L L O", it should be fine... > > Any ideas? > > Code:
> #define MERGE(a,b) a ## _ ## b
> #define hello_world "H E L L O"
>
> int foo()
> {
> char* p0;
> p0 = MERGE("hello", "world");
Code:
~~~~~~~~~~~~~~~~~~~~~~~~MERGE(hello,world); > > return 0;} > > > > thanks in advance, > George |
|
![]() |
| Outils de la discussion | |
|
|