Board index » cppbuilder » Linker problems!!!!!? Abs bug!!! Initialization stuff

Linker problems!!!!!? Abs bug!!! Initialization stuff

I had a very nice working application.  Made few slight changes - added
a single call to the abs function - now get exception error as soon as
program starts during initialization.

The following changes were made:

Old line:   i = i + 1
New line: i = i + abs(1)

Stack trace shows:

Forms::TScreen::SetCursor(Self=NULL, Index ...)     // self should not
be NULL
Teeprocs::initialization
__startup

Apparently the TChart initialization code in Teeprocs is getting called
before the global TSCreen object is created.  (Breakpoint on
TScreen.Create doesn't get hit.)

If I change the abs to labs, no problems.

Any thoughts on whats wrong and how to fix in case of other bizarre
related problems?  Thanks in advance.

Jim

 

Re:Linker problems!!!!!? Abs bug!!! Initialization stuff


Hi,

Quote
> Forms::TScreen::SetCursor(Self=NULL, Index ...)    
> be NULL
> Teeprocs::initialization
> __startup

Which version of BCB? I ask because that sounds like BCB3
problem that showed up when linking statically and when
certain packages were installed. It was fixed in the patch.
If that's not your version maybe try deleting all intermediates
(especially the linker state file (*.il?) if you use them),
and build all. Also, because it sounds similar to the other
problem maybe try building both when using and not using
packages?

--Craig

Re:Linker problems!!!!!? Abs bug!!! Initialization stuff


Using BC5 everything is deleted.  If I delete the line with abs(),
everything works fine.  Add it back in and then it causes problem.

Any other ideas?

Jim

Quote
Craig Farrell wrote:
> Hi,

> > Forms::TScreen::SetCursor(Self=NULL, Index ...)
> > be NULL
> > Teeprocs::initialization
> > __startup

> Which version of BCB? I ask because that sounds like BCB3
> problem that showed up when linking statically and when
> certain packages were installed. It was fixed in the patch.
> If that's not your version maybe try deleting all intermediates
> (especially the linker state file (*.il?) if you use them),
> and build all. Also, because it sounds similar to the other
> problem maybe try building both when using and not using
> packages?

> --Craig

Re:Linker problems!!!!!? Abs bug!!! Initialization stuff


Quote
>If I delete the line with abs(),
> everything works fine.  Add it back in and then it causes problem.

How weird.

Quote

> Any other ideas?

All I can think of to try would be to experiment with
the inline expansion switch (because it is an inline
function). The switch is at Project Options Compiler.

Also view the makefile source and look for anything
odd in the linker area:
  <LINKER>
    <ALLOBJ value="c0w32.obj $(PACKAGES) Memmgr.Lib sysinit.obj
$(OBJFILES)"/>
    <ALLRES value="$(RESFILES)"/>
    <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib"/>

Which you could compare to another project that uses abs() successfully,

--Craig

Re:Linker problems!!!!!? Abs bug!!! Initialization stuff


All Linker options look fine, inline expansion switch doesn't change
anything.

Temporary solution - created a "myAbs" function and removed abs from source
file.

Became productive again until exact same error (Teeprocs initialization
before global screen object created - it's now easy for me to spot) when
added:

  if (!flags.Length()) flags = " ";    // this line caused the crash

However:

  if (flags == "") flags = " ";    // ran just fine

So now I can't use AnsiString.Length() in this particular file!  However,
other files in the project DO use both the abs function and the Length
function!!

Any other ideas?  One last possible clue, I don't use run-time packages or
the dynamic RTL.

Thanks again,

Jim

Quote
> All I can think of to try would be to experiment with
> the inline expansion switch (because it is an inline
> function). The switch is at Project Options Compiler.

> Also view the makefile source and look for anything
> odd in the linker area:
>   <LINKER>
>     <ALLOBJ value="c0w32.obj $(PACKAGES) Memmgr.Lib sysinit.obj
> $(OBJFILES)"/>
>     <ALLRES value="$(RESFILES)"/>
>     <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib"/>

> Which you could compare to another project that uses abs() successfully,

> --Craig

Re:Linker problems!!!!!? Abs bug!!! Initialization stuff


Fixed problem!

Turned off pragma(smart_init) and now everything is fine again.  Real cause of
problem is unclear - PERHAPS it's because the name of the CPP file was
MESSAGES.CPP and the linker was getting confused with MESSAGES.PAS/DCU???
Haven't had a chance to go back and check thoroughly.

Jim

Other Threads