beautypg.com

Exception debug messages, C++ name mangling, Exception debug messages c++ name mangling – Rockwell Automation 2711P Software Development Kit User Manual User Manual

Page 98

background image

Publication 2711P-UM005A-EN-P - March 2007

98 Messages

Exception Debug Messages

PanelView Plus CE supports an exception handler named crashlog.exe
that dumps exception debug messages to a text file at \Storage
Card\Exceptions.log

To enable the Exception Logger, run the program named
DebugOptions.exe that is distributed in the Utilities folder on the
PanelView Plus CE Accessories CD, Part Number 77159-951-55. The
exception logger will run in the background until an exception occurs
that is not handled by the application.

C++ Name Mangling

In C++, name decoration or mangling is necessary to resolve
ambiguities that arise in C++ from having overloaded C++ functions
with the same name but different parameters. The compiler generates
a string that contains an undecorated (literal) name followed by a
string of characters that the compiler and linker use to retain type
information. Thus, the declarations are made type-safe even though
the names are the same.

When linking a C library into a C++ program, a link error LNK2001:
unresolved external symbol int __cdecl FuncName(unsigned long)
(?FuncName@@YAHK@Z) occurs because the mangled function name,
with the decorator @@YAHK@Z after the real function name is
incompatible with the C name. The workaround is to explicitly tell the
compiler not to mangle the function name. You can force it to treat
the name as a straight C-style name (no mangling) by using extern C
to prototype the function as follows:

extern C BOOL FuncName(DWORD);

The header files have the logic to declare all the prototypes as extern
C if __cplusplus is defined, which embedded Visual C++ 3.0 should
treat as being defined if compiling a C++ file. If you have trouble,
check your eVC settings or manually add a prototype with the extern
C so that the name is not mangled and it can link.