<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>ColdFire/68K Microcontrollers and Processors中的主题 Re: referensing global labels fails</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127609#M530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Daniel,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I add parenthesis I get following error:&lt;/DIV&gt;&lt;DIV&gt;Link Error&amp;nbsp;&amp;nbsp; : Undefined : "__init()"&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;I do not have such error without them.&lt;/DIV&gt;&lt;DIV&gt;Any ideas?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 24 Mar 2007 03:09:36 GMT</pubDate>
    <dc:creator>Veter</dc:creator>
    <dc:date>2007-03-24T03:09:36Z</dc:date>
    <item>
      <title>referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127605#M526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I am trying to reference global label located in the startup.s source from *.cpp file.&lt;/DIV&gt;&lt;DIV&gt;The error message states that label is "Undefined".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Assembly code:&lt;/DIV&gt;&lt;DIV&gt;.section&amp;nbsp;.init$00,2,C&lt;/DIV&gt;&lt;DIV&gt;.global ___init&lt;BR /&gt;___init&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;; Linker places .init sections from other modules, containing&lt;BR /&gt;; calls to initialize global objects, here.&lt;/DIV&gt;&lt;DIV&gt;.section&amp;nbsp;.init$99,2,C&lt;/DIV&gt;&lt;DIV&gt;rts&amp;nbsp;&amp;nbsp;&amp;nbsp;; Return from ___init.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;C++ code:&lt;/DIV&gt;&lt;DIV&gt;extern void ___init(void);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;static int init_main_guts(void)&lt;BR /&gt;{&lt;/DIV&gt;&lt;DIV&gt;...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;/* initialize constructors&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;BR /&gt;&amp;nbsp;___init();&lt;/DIV&gt;&lt;DIV&gt;...&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What am I doing wrong?&lt;/DIV&gt;&lt;DIV&gt;I am using CodeWarrior Development Studio for ColdFire Architectures Version 6.3, Build 14.&lt;/DIV&gt;&lt;DIV&gt;My target is MCF5307.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you!&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2007 21:47:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127605#M526</guid>
      <dc:creator>Veter</dc:creator>
      <dc:date>2007-03-22T21:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127606#M527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The CodeWarrior C compiler adds an underscore to the start of every function name, but in assembler you need to add it yourself.&lt;BR /&gt;&lt;BR /&gt;Thus a function in the C source code called foo() needs to be referred to as "_foo" in the assembler source.&lt;BR /&gt;&lt;BR /&gt;It looks like you've got one too many '_' characters in the ___init() call in main.c&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Simon&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2007 23:56:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127606#M527</guid>
      <dc:creator>SimonMarsden_de</dc:creator>
      <dc:date>2007-03-22T23:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127607#M528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;That is correct. There is one extra "_" character. Olso "__init()" does not need parenthesis. The working code has "__init;".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2007 23:58:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127607#M528</guid>
      <dc:creator>Veter</dc:creator>
      <dc:date>2007-03-22T23:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127608#M529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Veter wrote:&lt;BR /&gt;&lt;DIV&gt;Olso "__init()" does not need parenthesis. The working code has "__init;".&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Thank you.&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;
__init;
&lt;/PRE&gt;&lt;BR /&gt;is an statement without any side effect in C. Legal, but useless.&lt;BR /&gt;So if you do want __init to be called, add the parenthesis again.&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2007 05:28:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127608#M529</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-03-23T05:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127609#M530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Daniel,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I add parenthesis I get following error:&lt;/DIV&gt;&lt;DIV&gt;Link Error&amp;nbsp;&amp;nbsp; : Undefined : "__init()"&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;I do not have such error without them.&lt;/DIV&gt;&lt;DIV&gt;Any ideas?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Mar 2007 03:09:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127609#M530</guid>
      <dc:creator>Veter</dc:creator>
      <dc:date>2007-03-24T03:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127610#M531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I just noted one little word in the initial post:&lt;BR /&gt;&lt;PRE&gt;
C++ code:
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Does this mean init_main_gut is contained in a C++ file?&lt;BR /&gt;Well, that would explain it. In order to use C (or assembly for that matter) stuff from C++, it has to be explicitly given the C linkage.&lt;BR /&gt;&lt;PRE&gt;
#ifdef __cplusplus
extern "C" {
#endif
extern void __init(void);
#ifdef __cplusplus
}
#endif

static int init_main_guts(void)
{
...
 /* initialize constructors    */
 __init();
...
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also something to check: can you disassemble both the assembly and the C++ (or C) file,&lt;BR /&gt;and compare how the two __init names look like. They have to be identical.&lt;BR /&gt;To disassemble, use the context menu in the project window. There is also a preference panel to configure the disassembler.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Mar 2007 07:34:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127610#M531</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-03-24T07:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: referensing global labels fails</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127611#M532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;That was it.&lt;/DIV&gt;&lt;DIV&gt;Including 'extern "C" {}' directive solved the problem.&lt;/DIV&gt;&lt;DIV&gt;Dissasemblies for both sources look the same now.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you!&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2007 20:21:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/referensing-global-labels-fails/m-p/127611#M532</guid>
      <dc:creator>Veter</dc:creator>
      <dc:date>2007-03-26T20:21:15Z</dc:date>
    </item>
  </channel>
</rss>

