Unterschied zwischen BCC32 und BCC32C -ObjektlebensdauerC++

Programme in C++. Entwicklerforum
Anonymous
 Unterschied zwischen BCC32 und BCC32C -Objektlebensdauer

Post by Anonymous »

Ich habe eine Cross -Plattform C ++ -Anwendung mit C ++ Builder 10.1 Berlin und ein Problem damit, die Lebensdauerhandhabung von Objekten zu verstehen, in diesem Fall, die außerhalb der Klasse deklariert sind. Die CPP -Datei sieht so aus: < /p>
#include
#pragma hdrstop
#include "FmrMain.h"
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;

const String Hello = "Hello";

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ShowMessage(Hello);
}

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ShowMessage(Hello);
}
< /code>
Ich kompile dies mit dem Clang Enhanced C ++ 11 Compiler BCC32C, führen Sie die Anwendung aus und schließen Sie das Formular erneut. Wenn tform1 :: FormDestroy Hello genannt wird, wird bereits zerstört. Wenn ich den Code für Win32 mit dem klassischen Compiler BCC32 kompiliere, wird die Zeichenfolge nach Formdestroy zerstört. Warum verhält sich der Clang -basierte Compiler hier anders?class Foo {
public:
Foo(){};
~Foo(){}
};
Foo A;

//--------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------

__fastcall TForm1::~TForm1()
{
}
< /code>
Die Schöpfungs- und Zerstörungs -Wege ist so. Ich habe die Anrufstapel hinzugefügt. />
: 00405070 __cxx_global_var_init3 ()

: 004052a3 _global__i_a ()

: 00405AB7; ~ Foo

: 321fa2b7; C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\CC32C240MT.DLL

:321fa6ff CC32C240MT.__wstartup + 0xbb
  • create Form1 < /li>
    < /ol>

    : 004052ec tform1 (this =: 00402422, __ctor_flag = '\ 0')

    : 0085c1399 fmx240.@fmx@forms@tapplication@createForm $ qqrxp17System@tmetaClassspv + 0x5d

    : 0085c349 fmx240.@fmx@forms@tapplication@realcreatreforms $ qqrv + 0x81 < /P. start = "4">
    Zerstöre foo < /li>
    < /ol>

    : 004052d0 ~ foo (this =: 0040B7DC)

    : 0040509e __dtor_a ()

    : 321f624624624662466246624662466246624662466246624662466246624624624624624624624624624624624624624624624624624624624624624624. CC32C240MT.___call_atexit_procs + 0x52

    :321f671c CC32C240MT.___exit + 0x20


    destroy Form1
:00405868 ~TForm1(this=:5016E698)

bcc32 (Classic borland compiler)
  • create Foo
: 00404950 foo :: foo (this =: 00409b74)

: 004048a0 stcon0 < /em> ()

: 00405727; Iot

: 322190f1; C: \ Programmdateien (x86) \ Embarcadero \ Studio \ 18.0 \ bin \ cc32240mt.dll>: 322193b5 CC32240MT .__ Wstartup + 0xa5 < /p>
bra Blockquote>

:00404994 TForm1::TForm1(this=:02F2AE20, Owner=:02F39620)

:0095c139 fmx240.@Fmx@Forms@TApplication@CreateForm$qqrxp17System@TMetaClasspv +
0x5d

: 0095C349 fmx240.@fmx@forms@tapplication@realcreateForms $ qqrv + 0x81 < /p>
< /blockquote>

:00404ABC TForm1::~TForm1(this=:02F2AE20)


[*]destroy Foo
[/list]

:00404978 Foo :: ~ foo (this =: 00409b74)

: 0040493f stdes0 < /em> ()

: 0040573f; iRoot>

: 3221910f; C: \ Programmdateien (x86) \ Embarcadero \ Studio \ 18.0 \ bin \ cc32240mt.dll

: 3221915b; C: \ Programme (x86) \ Embarcadero \ Studio \ 18.0 \ bin \ cc32240mt.dll>: 3221944a; C: \ Programmdateien (x86) \ Embarcadero \ Studio \ 18.0 \ bin \ cc32240mt.dll

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post