English 中文(简体)
采用微粒或代码改动的压倒性计算基型
原标题:overriding enumeration base type using pragma or code change

<<>Problem>:

我正在使用一个大型的C/C++代码基数,该基数按缺省32倍(打字型)计算。

该法典还有很多条线+嵌入式的组装,它们把 en作为惯性类型处理,而且在许多情况下,um数据被用作32条轨道旗帜。

当用真实情况ARM RV 2.2汇编者汇编这一代码时,我们开始发现许多问题,因为真实情况汇编者决定,自动地根据表格的价值确定如下:rel=“nofollow noreferer”>。 http://www.keil.com/support/man/docs/armccref/armccref_Babjdhe.htm

例如,

审议以下要点:

enum Scale {
    TimesOne, //0
    TimesTwo, //1
    TimesFour, //2
    TimesEight, //3
};

该国旗被用作32条轨道旗。 但是,汇编者优化了这一平台,使之达到未经签字的果园类型。

采用Senum_is_int codificationer办法,不是我们案件的良好解决办法,因为它把所有内容转换为32条轨道,这将打破与未经——enum_is_int编纂的任何外部法典的互动。

这份警告载于RVCT汇编器和办公室;图书馆指南。

The --enum_is_int option is not recommended for general use and is not required for ISO-compatible source. Code compiled with this option is not compliant with the ABI for the ARM Architecture (base standard) [BSABI], and incorrect use might result in a failure at runtime. This option is not supported by the C++ libraries.

<<><><><><>>>>><><><>>>>>

如何在不影响价值排序的情况下将所有基类(通过手编码改动)改为使用32比值?

enum Scale {
    TimesOne=0x00000000,
    TimesTwo, // 0x00000001
    TimesFour, // 0x00000002
    TimesEight, //0x00000003
};

我尝试了上述变化。 但是,汇编者也优化了我们坏的uck子。

这里有一些yn。 NET

注:

这一标准是ISO C++标准,而ARM编纂者缺乏标准?

在ARM RVCT 2.2汇编者中,没有控制这一 en。 是否有任何隐蔽的rag?

最佳回答

我知道,许多窗口的负责人使用如下:

enum SOME_ENUM {
    ONE = 1,
    TWO = 2,
    //...
    FORCE_DWORD = 0x7FFFFFFF
};
问题回答

C++11:

enum class Scale : uint32_t {
   TimesOne, //0
   TimesTwo, //1
   TimesFour, //2
   TimesEight, //3
};

“视觉演播室2012”和“gcc 4.4.6”这两个选项都支持这一选择(早期版本也可能)。





相关问题
Finding the Highest Value in an Enumeration

I m writing a method which determines the highest value in a .NET enumeration so I can create a BitArray with one bit for each enum value: pressedKeys = new BitArray(highestValueInEnum<Keys>());...

Conversion of Enum to Enumerable

To convert Enum to Enumerable ,I use public enum Flags { Trivial=1, Minor, Major, Critical } IEnumerable<int> n = Enumerable.Range((int)Flags.Trivial, (...

Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

Enum scoping issues

I try to keep things as local as possible, so I put enums at class scope, even if they are shared between two classes (I put it in the class that "goes better" with it.) This has worked out great, but ...

How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String ...

C++ enum value initialization

I have an enum declared in my code as: enum REMOTE_CONN { REMOTE_CONN_DEFAULT = 0, REMOTE_CONN_EX_MAN = 10000, REMOTE_CONN_SD_ANNOUNCE, REMOTE_CONN_SD_IO, REMOTE_CONN_AL, ...

WCF: Enforce equal DataContracts on both sides

I m wondering if it is possible to have WCF make sure that the DataContracts on both sides of a connection are exactly the same (and throw an exception when trying to connect if they are not). For ...

热门标签