CompuServe Thread

Undef C++ link symbol

3 messages in this thread
#45364From: Joe VeazeyJan 26, 1995 1:54 AM
I have been working on getting flex++ 2.4.7 and bison++ 1.21-8 ported over to the Amiga. Both seem to be working ok with SAS/C 6.51, with full optimization. I am having a problem with the generated C++ lexer I am building with Flex++. At link time, I am getting the following undefined symbol: @__write__7ostreamFPCci (Both of those long underscores are actually 2 underscores _). It asks me to define a stub, so I hit enter and let the slink step finish. According to the SAS/C user's guide, the @ means registerized, and a single underscore is always added to external symbols by the linker (p.134). I then use CPR to run it and I can get to the actual call in my source code that didn't get resolved by slink: void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout->write( buf, size ); } yyout is defined this way: ostream* yyout; // output sink for default LexerOutput The usual iostream.h is included way above all this. I searched thru the names in LIB:sc.lib, and found these external names: @write__7ostreamFPCci (Again with 2 underscores). When you demangle this name you get: ostream::@write(const char*,int) just like you would expect. The compiles go fine, no errors, 3 minor warnings about assigning an unsigned int to a signed, but no other messages. WHAT'S happening? #include <disclaimer.h>
#45408From: Doug WalkerJan 29, 1995 11:04 AM
Hi Joe – Your unresolved symbol error comes from an unfortunate interaction between one of the SAS/C C header files and iostream.h. The C header file <fcntl.h> has the following #define: #define write __write The reason for this is that ANSI required us to rename the UNIX compatibility function "write" to the name "__write" since it is a non-ANSI function invoked by ANSI library functions. To keep user code from breaking, we added the #define so calls to write() would be changed to calls to __write(). Well, unfortunately this conflicts with a *member function* called write() in the iostreams stuff. When we release the 6.55 patch, <fcntl.h> will be modified to NOT do that #define if the file is included from C++. If you want, you can make this change to your copy early: Edit <fcntl.h> and wrap the #defines for open, read, write, and close with #ifndef __cplusplus: #ifndef __cplusplus #define open __open #define close __close #define read __read #define write __write #endif Sorry about the problem, and I hope this will fix things up. –Doug
#45426From: Joe VeazeyJan 31, 1995 5:02 AM
Yes, this fixed it! Thanks very much. Eagerly awaiting 6.55…. #include <disclaimer.h>