flags

What are the gcc predefined macros for the compiler's version number?

只谈情不闲聊 提交于 2019-11-27 01:04:39
问题 I have run into a bug with gcc v3.4.4 and which to put an #ifdef in my code to work around the bug for only that version of the compiler. What are the GCC compiler preprocessor predefined macros to detect the version number of the compiler? 回答1: From the gnu cpp manual... __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ These macros are defined by all GNU compilers that use the C preprocessor: C, C++, Objective-C and Fortran. Their values are the major version, minor version, and patch level of

What is a flag variable?

故事扮演 提交于 2019-11-26 23:09:59
问题 Recently I just came across this term and I had no idea as to what purpose it serves? I am little unsure about when to use a flag variable and how to go about it? I Googled it but there were not any specific examples related to it (in the context of JavaScript). 回答1: Flag Variables Defined and Uses says: A flag variable, in its simplest form, is a variable you define to have one value until some condition is true, in which case you change the variable's value. It is a variable you can use to

GCC: how is march different from mtune?

放肆的年华 提交于 2019-11-26 22:37:28
问题 I tried to scrub the GCC man page for this, but still don't get it, really. What's the difference between -march and -mtune ? When does one use just -march , vs. both? Is it ever possible to just -mtune ? 回答1: If you use -march then GCC will be free to generate instructions that work on the specified CPU, but not on (typically) earlier CPUs in the architecture family. If you use -mtune , then the compiler will generate code that works on any of them, but will favour instruction sequences that

about assembly CF(Carry) and OF(Overflow) flag

ぃ、小莉子 提交于 2019-11-26 20:08:35
It's known that CF indicates unsigned carry out and OF indicates signed overflow. So how does an assembly program differentiate between unsigned and signed data since it's only a sequence of bits? (Through additional memory storage for type information, or through positional information or else?) And could these two flags be used interchangeably? Norman Ramsey The distinction is in what instructions are used to manipulate the data, not the data itself. Modern computers (since circa 1970) use a representation of integer data called two's-complement in which addition and subtraction work exactly

Perl flags -pe, -pi, -p, -w, -d, -i, -t?

☆樱花仙子☆ 提交于 2019-11-26 19:34:08
I have seen lots of ways of running Perl code or scripts, with different flags. However, when I try to google for what each flag means, I mainly get results to generic Perl sites and no specific information regarding the flags or their use is found there. Below are the flags that I encounter most often, and I don't have a clue what they mean: perl -pe perl -pi perl -p perl -w perl -d perl -i perl -t I will be very grateful if you tell me what each of those mean and some use cases for them, or at least tell me a way of finding out their meaning. paxdiablo Yes, Google is notoriously difficult

Start new Activity and finish current one in Android? [duplicate]

寵の児 提交于 2019-11-26 19:22:10
问题 This question already has answers here : How to finish current activity in Android (7 answers) Closed 5 years ago . Currently I'm starting a new Activity and calling finish on a current one. Is there any flag that can be passed to Intent that enables finishing current Activity without a need to call finish manually from code? 回答1: You can use finish() method or you can use: android:noHistory="true" And then there is no need to call finish() anymore. <activity android:name=".ClassName" android

Why do enum permissions often have 0, 1, 2, 4 values?

大憨熊 提交于 2019-11-26 18:45:16
问题 Why are people always using enum values like 0, 1, 2, 4, 8 and not 0, 1, 2, 3, 4 ? Has this something to do with bit operations, etc.? I would really appreciate a small sample snippet on how this is used correctly :) [Flags] public enum Permissions { None = 0, Read = 1, Write = 2, Delete = 4 } 回答1: Because they are powers of two and I can do this: var permissions = Permissions.Read | Permissions.Write; And perhaps later... if( (permissions & Permissions.Write) == Permissions.Write ) { // we

How to Compare Flags in C#?

痞子三分冷 提交于 2019-11-26 18:42:27
I have a flag enum below. [Flags] public enum FlagTest { None = 0x0, Flag1 = 0x1, Flag2 = 0x2, Flag3 = 0x4 } I cannot make the if statement evaluate to true. FlagTest testItem = FlagTest.Flag1 | FlagTest.Flag2; if (testItem == FlagTest.Flag1) { // Do something, // however This is never true. } How can I make this true? Phil Devaney In .NET 4 there is a new method Enum.HasFlag . This allows you to write: if ( testItem.HasFlag( FlagTest.Flag1 ) ) { // Do Stuff } which is much more readable, IMO. The .NET source indicates that this performs the same logic as the accepted answer: public Boolean

Disable keep screen on

梦想的初衷 提交于 2019-11-26 18:10:14
问题 I used: getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); How do I resume to Default state (no-keep-on)? 回答1: I think this should do it: getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); See API for details. 回答2: If you instead set a flag android:keepScreenOn="true" (documentation) only on the views that need to keep the screen on, you wouldn't need to reset the flag manually. 回答3: Another approach getWindow().setFlags(this

Checking flag bits java

蹲街弑〆低调 提交于 2019-11-26 17:38:51
问题 I have a problem with flag bits. I have an int variable to hold flags. First I set some flags to that variable. Later I need check how many flags were set in that variable. But I don't know to do it. 回答1: To check to see if a bit value is set: int value = VALUE_TO_CHECK | OTHER_VALUE_TO_CHECK; if ((value & VALUE_TO_CHECK) == VALUE_TO_CHECK) { // do something--it was set } if ((value & OTHER_VALUE_TO_CHECK) == OTHER_VALUE_TO_CHECK) { // also set (if it gets in here, then it was defined in //