This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/TMS320F28377S:编译器#39;s 分配顺序问题

Guru**** 2458160 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/728087/compiler-tms320f28377s-compiler-s-allocation-order-issue

器件型号:TMS320F28377S

工具/软件:TI C/C++编译器

您好!

我有一个与编译器相关的问题、

我按如下顺序定义了常量:
const int constint0=0;
const int constint1 = 0;
const int constint2 = 0;
const int constint3=0;
const int constint4 = 0;
const int constint5=0;
const int constint6 = 0;
const int constint7 = 0;
const int constint8 = 0;
const int constint9=0;
const int constint10 = 0;
const int constint11 = 0;
const int constint12 = 0;
const int constint13 = 0;
const int constint14 = 0;

但是、".map"中的地址不会按顺序分配:
0000b000 2c0 (0000b000)_constint7
0000b001 2c0 (0000b000)_constint8
0000b002 2c0 (0000b000)_constint6
0000b003 2c0 (0000b000)_constint4
0000b004 2c0 (0000b000)_constint5
0000b005 2c0 (0000b000)_constint3
0000b006 2c0 (0000b000)_constint13
0000b007 2c0 (0000b000)_constint14
0000b008 2c0 (0000b000)_constint12
0000b009 2c0 (0000b000)_constint10
0000b00a 2c0 (0000b000)_constint11
0000b00b 2c0 (0000b000)_constint2
0000b00c 2c0 (0000b000)_constint9
0000b00d 2c0 (0000b000)_constint1
0000b00e 2c0 (0000b000)_constint0

我希望这些可以按顺序分配、 您能给我一些建议吗?

谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    元、

    您的问题将转给相应的所有者。

    此致、
    Ozino
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    [报价用户="Yuan Tan63"]我希望可以按顺序分配这些资源, 您能给我一些建议吗?

    正如您发现的、编译器无需按照与源代码相同的顺序定义全局变量。

    您有两种解决方案需要考虑。  将所有这些变量放入一个结构中。  或者、在手工编码的汇编语言中声明所有这些变量。   有关汇编方法的详细信息、请参阅此帖子。

    谢谢、此致、

    乔治