Linker Error using TFormatedObject.NumberFormat

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
larry_bar56
Posts: 3
Joined: Mon Jan 07, 2008 8:15 pm

Linker Error using TFormatedObject.NumberFormat

Post by larry_bar56 »

I'm using XLSReadWriteII3.0 with Borland C++ Builder 6.

I use

c = XLS->Sheets->Items[0]->Cell[col][2];

to get a cell reference but if I try:

c->NumberFormat;

the project will not link with the following error:

[Linker Error] Unresolved external '__fastcall Formattedobj2::TFormattedObject::GetNumberFormatA()' referenced from C:\PROJECTS\XLS\XLSTEST.OBJ

Library path is set correctly. Other calls to XLS functions work. Any suggestions would be appreciated.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

The C++ preprocessor replaces the GetNumberFormat method with GetNumberFormatA. Right now there is no solution to this.


Lars Arvidsson
larry_bar56
Posts: 3
Joined: Mon Jan 07, 2008 8:15 pm

Post by larry_bar56 »

larsa wrote:Hello

The C++ preprocessor replaces the GetNumberFormat method with GetNumberFormatA. Right now there is no solution to this.


Lars Arvidsson
Why does the preprocessor do that? Is this a name mangling issue? I searched every .hpp file for any reference to GetNumberFormatA and found none. So, I believe you when you say the preprocessor is doing this, but why is that name not found in any library or object module? Plus, this is not true for SetNumberFormat which seems to work just fine. This seems very odd.

Larry
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

The name GetNumberFormat is #DEFINED in a windows api file (don't remember which), and replaced with GetNumberFormatA.


Lars Arvidsson
larry_bar56
Posts: 3
Joined: Mon Jan 07, 2008 8:15 pm

Post by larry_bar56 »

larsa wrote:Hello

The name GetNumberFormat is #DEFINED in a windows api file (don't remember which), and replaced with GetNumberFormatA.


Lars Arvidsson
Thanks! That allowed me to find a work around. I'll publish it here so others can use it as well. The file that defines GetNumberFormat is winnls.h (at least that's what I found with Borland C++ Builder 6). My application is not making use of anything from that header file (if you are using it, then this won't work for you).

My source file is named XLSTest.cpp and has a corresponding header file XLSTest.h. In the .h file I added preprocessor directives to undefine the GetNumberFormat. This has to go before the inclusion of XLSReadWriteII2.hpp. However, when you insert this code, Borland wants to then reinsert the XLSReadWriteII2 header file as XLSReadWriteII2.h (notice, not .HPP!) I couldn't figure out how to prevent this, so I just created an empty XLSReadWriteII2.h file in my project's directory and rebuilt my project. Now I can use the NumberFormat property of the cell in my code.

It's not pretty, but it works.

Here's what my XLSTest.h file looks like:

#include "XLSReadWriteII2.h" // Empty file to satisfy compiler
#ifdef GetNumberFormat
#undef GetNumberFormat
#endif
#include "XLSReadWriteII2.hpp" // Real XLSRW2 header file


- Larry
Post Reply