English 中文(简体)
uint64 旗帜或uint32 旗帜,向32位编造者提出职务理由?
原标题:uint64 flag or uint32 flag[2] for function argument to 32bit compiler?
  • 时间:2010-07-20 17:34:36
  •  标签:
  • c++

我对一些远洋旗国和这些旗帜有3232的变量。 这种变数被按价值推向某些职能。

我需要增加大约20条旗帜。 我的最佳选择是什么? 将其扩大到64个轨道,或将其视作2个轨道?

延伸到64个轨道,将导致我使用汇编展期,因为总长度为32个。 但是,使用阵列似乎导致更多的工作。

我的法典汇编了32和64个图书编集者,并在窗户、lin子和玉米上运行。

提前感谢。

最佳回答

我将使用STL专栏。 然后,我的遗体必须成为2人。 按照正常的计算,这只是计算公式中的指数。 也可使用<条码>查询和设计;bool>。

主要好处是portability,因为你的旗帜现在将适合正常的平台。

例如:

enum errorFlags { parity, framing, overrun, errorFlags_size };

std::bitset<errorFlags_size> flagSet;

. . .

// either of these set framing error condition
flagSet[framing] = true;
flagset.set(framing);

// either of these clear the framing error condition
flagSet[framing] = false;
flagset.reset(framing);

// this tests for the framing error condition
if (flagSet[framing])
{
    // we have a framing error
}
问题回答

你们是否知道借方歌子? 它希望:

struct Flags {
    unsigned int flag1 : 1;
    unsigned int flag2 : 1;
    unsigned int flag3 : 1;
}

因此。 上校之后的数字表明,如果你想向该成员表示,人数就会增加。 这是标准C++,而不是一些仓促的供应商延期。

http://msdn.microsoft.com/en-us/library/ewwyfdbe(VS.71).aspx“rel=“nofollow noretinger”http://msdn.microsoft.com/en-us/library/ewwyfdbe(VS.71).aspx

由于你正在使用C++,你可以书写一个替代类别,内部可以储存两个32个借方。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签