H
Henrik Goldman
Hi
I have a C++ construct which works fine on a number of platforms. However on
AIX using g++ 3.3.2 it gives a warning:
Here it is:
#include <stdio.h>
class c1
{
public:
char *GetBlah()
{
static char *szPrefix = "ABCD";
return szPrefix;
}
};
int main()
{
c1 c;
printf("%s\n", c.GetBlah());
return 0;
}
What I get is:
test2.cpp: In member function `char* c1::GetBlah()':
test2.cpp:11: warning: sorry: semantics of inline function static data `
char*szPrefix' are wrong (you'll wind up with multiple copies)
test2.cpp:11: warning: you can work around this by removing the
initializer
Isn't this valid code?
Thanks in advance.
-- Henrik
I have a C++ construct which works fine on a number of platforms. However on
AIX using g++ 3.3.2 it gives a warning:
Here it is:
#include <stdio.h>
class c1
{
public:
char *GetBlah()
{
static char *szPrefix = "ABCD";
return szPrefix;
}
};
int main()
{
c1 c;
printf("%s\n", c.GetBlah());
return 0;
}
What I get is:
test2.cpp: In member function `char* c1::GetBlah()':
test2.cpp:11: warning: sorry: semantics of inline function static data `
char*szPrefix' are wrong (you'll wind up with multiple copies)
test2.cpp:11: warning: you can work around this by removing the
initializer
Isn't this valid code?
Thanks in advance.
-- Henrik