Discussion:
About: CCS 3.2 compiler confuses function name with internal symbol ...
(too old to reply)
J. L. Schilling
2003-12-03 15:03:09 UTC
Permalink
I am porting a product to UnixWare 7.1.1 by re-compiling the source
code in C++ (already have a few ported to other Unix platforms). I
have a very strange compliation error that affects a few source code
listed as follow: [...]
The problem here is that your code is declaring and using member function
names "shutdown" and "send". This is improper, as the various POSIX
and X/Open UNIX standards specifications reserve these names for
the implementation. See for example
http://www.opengroup.org/onlinepubs/007908799/xns/namespace.html.

On some platforms using these reserved names doesn't cause any
difficulty. But on UnixWare 7 it does, because the implementation
supports networking API versionning by use of macros on these names.

So, the best solution is to change your application to not name its
own functions "shutdown" and "send".

If you can't do that, then make sure that the <sys/socket.h> is
including at the start of *every* header or source file that declares,
defines, or calls these functions. Then the macro change will be
applied consistently.

Having done this, you'll still have a problem because of your
use of the function "_shutdown". This happens to be what one of
the versionning macros changes "shutdown" to ... a double whammy!
You'll have to change that protected function to something else,
like "_prot_shutdown". Then everything should be ok.

Jonathan Schilling
clement tang
2003-12-09 01:58:28 UTC
Permalink
Yes, <sys/socket.h> defines a macro on shutdown and cause my
compliation problem. The marco defination is like this:

extern int shutdown(int, int);
static int _shutdown(int __a1, int __a2)
{
return (__NETLIB_LIBSOCKET_ALL_VERSIONED__() ?
_xshutdown(__NETLIB_VERSION__, __a1, __a2)
: shutdown(__a1, __a2));
}
#define shutdown _shutdown

Unfortunately, shutdown and send are also defined in CORBA
specification so I cannot rename those functions. Even if I rename
_shutdown(), it won't work because the preprocessor will convert
shutdown(int, char) function to _shutdown(int, char) and I will still
get compilation error. In fact, I have to undefine the marco shutdown
if it is defined, like this:

#ifdef shutdown
#undef shutdown
#endif

I just wonder if I don't use NETLIB (assume it is Netscape socket
lib), would that be fine?
J. L. Schilling
2003-12-09 19:38:08 UTC
Permalink
Post by clement tang
Yes, <sys/socket.h> defines a macro on shutdown and cause my
extern int shutdown(int, int);
static int _shutdown(int __a1, int __a2)
{
return (__NETLIB_LIBSOCKET_ALL_VERSIONED__() ?
_xshutdown(__NETLIB_VERSION__, __a1, __a2)
: shutdown(__a1, __a2));
}
#define shutdown _shutdown
Unfortunately, shutdown and send are also defined in CORBA
specification so I cannot rename those functions.
Then CORBA is in conflict with the UNIX standards, alas.
Post by clement tang
Even if I rename
_shutdown(), it won't work because the preprocessor will convert
shutdown(int, char) function to _shutdown(int, char) and I will still
get compilation error.
The idea is, in your source code have two functions, shutdown()
and _prot_shutdown(), where the first calls the second.

Then in your source code, always include <sys/socket.h> up front.

In your resulting object code, you will find that shutdown() became
_shutdown() ... but so what? The name in the object code doesn't
matter, unless you are trying to link against pre-existing libraries
that use that name (are you?). _prot_shutdown()'s name will remain
unchanged. This should get you by.
Post by clement tang
I just wonder if I don't use NETLIB (assume it is Netscape socket
lib), would that be fine?
No, the NETLIB has nothing to do with Netscape. All this macro stuff
is done to support different networking APIs within the same library.

Jonathan Schilling
clement tang
2003-12-09 23:21:12 UTC
Permalink
OK, I understand that now. However, shutdown and send is defined in
Corba idl and we generate some abstract CPP class with function name
shutdown and send. Also, we have other CPP class inherited from those
generated abstract class. Unless they agree to change the generated
code for UnixWare, we have to stick with shutdown and send.

In the meantime, if I undefine shutdown marco then what is the
possible consequence?
J. L. Schilling
2003-12-11 01:01:38 UTC
Permalink
Post by clement tang
OK, I understand that now. However, shutdown and send is defined in
Corba idl and we generate some abstract CPP class with function name
shutdown and send. Also, we have other CPP class inherited from those
generated abstract class. Unless they agree to change the generated
code for UnixWare, we have to stick with shutdown and send.
Unless your CORBA implementation comes with libraries that have these
methods defined within them, you could still get away with the
versioning substitution, if you made sure that <sys/socket.h> gets
included in all the stub routines generated by the IDL compiler.
(You might have to insert an edit step that runs after the compiler
to make this happen.)
Post by clement tang
In the meantime, if I undefine shutdown marco then what is the
possible consequence?
You go back in time ...
The older versions of the socket APIs use an older version
of the various datatypes, mostly structures. You can't mix
and match the two sets of datatypes. I'm not sure what if
any behaviorial/features are lost by going back.

Jonathan Schilling

Loading...