Board index » cppbuilder » TPrinter::GetPrinter() exception makes std C lib unusable..

TPrinter::GetPrinter() exception makes std C lib unusable..

Hi all,

I've run into a weird problem - calls to TPrinter::GetPrinter() lead to
failures in std C functions like atof() or fabs(). Eg

    double tmp = atof("123456789.1234");

results in tmp=1234923 or similiar. If this is not strangely enough, a
following dll loading seems to restore the original state and the C std
functions work again.

Has anyone noticed such strange things? Has anyone any clue how to
restore that original behaviour without loading a dll?

Thanks for any help/hints
Ali, kinda' clueless

PS: By the way, the global errno (retrieved via *__errno()) is 0.
--
Albrecht Fritzsche, Software Developer
alfabet meta-modeling AG,
leibnizstr. 53, 10629 berlin, germany
http://www.alfabet.de

 

Re:TPrinter::GetPrinter() exception makes std C lib unusable..


Hi, Albrecht.

Quote
Albrecht Fritzsche wrote:

> Hi all,

> I've run into a weird problem - calls to TPrinter::GetPrinter() lead to
> failures in std C functions like atof() or fabs(). Eg

>     double tmp = atof("123456789.1234");

> results in tmp=1234923 or similiar. If this is not strangely enough, a
> following dll loading seems to restore the original state and the C std
> functions work again.

Hmmm.  Well, I assume that you are actually calling
Printer()->GetPrinter(), not TPrinter::GetPrinter() since the latter
should not compile.

This sounds suspiciously like a stray pointer corrupting something at
runtime or a broken incremental linker file.  I would first disable
incremental linking and try deleting any *.il? and *.tds files in the
project directory and do a full rebuild.

If you were not using incremental linking, perhaps you changed compile
or linkage options without doing a full rebuild.  A full rebuild should
fix that.

If you still get errors, I would set a breakpoint on the above line and
make sure that the value passed to atof() was what you expected.  If
not, something is corrupting storage prior to the call.  If so,
something may be corrupting the tmp variable after the call.

If none of the above helps, and you still find that subsequently loading
a DLL appears to fix the problem, check to see if you are using dynamic
runtime libraries.  I would disable that as well and do a full rebuild.
This seems a long-shot though....

HTH.

robert

Re:TPrinter::GetPrinter() exception makes std C lib unusable..


Quote
Robert Dunn wrote:

> This sounds suspiciously like a stray pointer corrupting something at
> runtime

nop

Quote
> or a broken incremental linker file.  I would first disable
> incremental linking and try deleting any *.il? and *.tds files

cool - how have you guessed that:-) honestly, i never had such
a linker problem before (i am using BCB just for a year or so)
and have found that incremental linker problem just by accident
just two days ago - caused by a somehow corrupted .bpr file.

Therefore even a rebuild hasn't solved the problem...

Thanks
Ali
--
Albrecht Fritzsche, Software Developer
alfabet meta-modeling AG,
leibnizstr. 53, 10629 berlin, germany
http://www.alfabet.de

Re:TPrinter::GetPrinter() exception makes std C lib unusable..


Hi, Albrecht.

Quote
Albrecht Fritzsche wrote:

> > or a broken incremental linker file.  I would first disable
> > incremental linking and try deleting any *.il? and *.tds files

> cool - how have you guessed that:-) honestly, i never had such
> a linker problem before (i am using BCB just for a year or so)
> and have found that incremental linker problem just by accident
> just two days ago - caused by a somehow corrupted .bpr file.

> Therefore even a rebuild hasn't solved the problem...

Because anytime I get truly weird problems, incremental linking is the
first thing that I check. <g>

If you have not already, you can recreate the *.bpr.  Save all of your
files, create a new project, set the project options, and save the
project.  Exit the IDE and copy over the old files (except for the
*.bpr).  Reopen the IDE and add back any additional *.cpp files.  You
may get warnings about missing components when you open the project.
Simply add them back and set the properties and events.

HTH.

robert

Other Threads