pragma

Detect if a table contains a column in Android/sqlite

陌路散爱 提交于 2019-12-01 18:53:42
问题 So I have an app on the market, and with an update I want to add some columns to the database. No problems so far. But I want to detect if the database in use is missing these columns, and add them if this is the case. I need this to be done dynamically and not just after the update to the new version, because the application is supposed to still be able to import older databases. Normally I would be able to use the PRAGMA query, but Im not sure how to do this with Android. I cant use execSQL

Did `#pragma once` make it into C++0x?

六月ゝ 毕业季﹏ 提交于 2019-12-01 16:16:36
The title says it all. Have #pragma once been standardized for C++0x? I don't know any compiler that doesn't provide an implementation of it, with almost always the same semantics and name. All #pragma directives cause the implementation to behave in an implementation defined way. This hasn't changed between C++03 and the latest C++0x draft (n3225.pdf). Include guards are the portable alternative. Sun C++ compiler (Solaris) does not implement it. And no, it's not in C++0x drafts. It's also trivial to implement using #ifdef. What's the guiding principal for the new version? Implement everything

Alignment of struct didn't work with #pragma pack

本小妞迷上赌 提交于 2019-12-01 13:39:34
I have a c++ structure: struct a { char b; int c; int d[100]; }; The size of the struct should be 405 bytes. I saw that the size of the struct is 408 bytes. The reason is the alignment to 8 bytes after the integer "c". The array "d" should start at the 6th byte of the struct and not at the 9th byte. I used #pragma pack(1) but it didn't solve the problem. I cannot change the order of fields in the struct. Do you have any idea how can I solve this problem? Thanks! The fault packing for most compilers I use is that objects align on their own size. The default packing for your struct would insert

Does FENV_ACCESS pragma exist in C++11 and higher?

南楼画角 提交于 2019-12-01 09:42:55
Reading a bug report for clang not supporting FENV_ACCESS pragma I've come across a comment : Setting the rounding mode without using #pragma STDC FENV_ACCESS ON invokes undefined behavior. See C11 7.6.1/2. (This pragma does not exist in C++, so <cfenv> is unusable, but that's not our fault...) Does this pragma really not exist in C++, rendering <cfenv> unusable? I've tried to search for it in the C++11 standard, but it really isn't mentioned at all. Are pragmas inherited from C along with function prototypes? Or are they actually not needed to avoid UB, since the C++ standard doesn't say

C++ pragma GCC system_header directive

那年仲夏 提交于 2019-12-01 06:14:01
What this C++ directive do: "#pragma GCC system_header"? Tim I googled and got this : #pragma GCC system_header This pragma takes no arguments. It causes the rest of the code in the current file to be treated as if it came from a system header. Section 2.7 System Headers. More info on System headers 2.7. System Headers The header files declaring interfaces to the operating system and runtime libraries often cannot be written in strictly conforming C. Therefore, GCC gives code found in system headers special treatment. All warnings, other than those generated by #warning (Chapter 5 Diagnostics)

Disable structure padding in C without using pragma

会有一股神秘感。 提交于 2019-12-01 03:28:43
How can I disable structure padding in C without using pragma? There is no standard way of doing this. The standard states that padding may be done at the discretion of the implementation. From C99 6.7.2.1 Structure and union specifiers , paragraph 12: Each non-bit-field member of a structure or union object is aligned in an implementation-defined manner appropriate to its type. Having said that, there's a couple of things you can try. The first you've already discounted, using #pragma to try and convince the compiler not to pack. In any case, this is not portable. Nor are any other

OpenMP: conditional use of #pragma

血红的双手。 提交于 2019-11-30 17:57:45
I'm using OpenMP to improve my program efficiency on loops. But recently I discovered that on small loops the use of this library decreased performances and that using the normal way was better. In fact, I'd like to use openMP only if a condition is satisfied, my code is #pragma omp parallel for for (unsigned i = 0; i < size; ++i) do_some_stuff (); But what I want to do is to disable the #pragma if size is small enough i.e.: if (size > OMP_MIN_VALUE) #pragma omp parallel for for (unsigned i = 0; i < size; ++i) do_some_stuff (); But does not work, the better way is to write the loop twice but I

linking with a pragma with g++

こ雲淡風輕ζ 提交于 2019-11-30 14:02:58
问题 In Visual C++, one may link to a library in the code itself by doing #pragma comment (lib, "libname.lib") . Is something similar possible in g++? 回答1: The Boost Config library has some support for autolinking, using the relevant compiler-specific code for the particular compiler. However, the docs note that the GCC toolchain doesn't support autolinking: Auto-Linking Most Windows compilers and linkers have so-called “auto-linking support,” which eliminates the second challenge. Special code in

#pragma mark not showing in methods in Xcode 4.0

只谈情不闲聊 提交于 2019-11-30 11:02:36
In Xcode Version 4.0 I notice that #pragma marks within methods are no longer showing up in the Jump Bar. The only #pragma marks that are showing up are those that are between methods. I was using these #pragma marks to make it easy to quickly organize and get to information that appears in different sections of my tableviews and I would really like to get that functionality back. Anyone know how to get them to appear again? I'm also experiencing this problem. A pragma mark added before the first method will not show up. For example, this will not work: @implementation RandomClass #pragma mark

List of #pragma warning disable codes and what they mean

為{幸葍}努か 提交于 2019-11-30 10:55:53
The syntax for disabling warnings is as follows: #pragma warning disable 414, 3021 Or, expressed more generally: #pragma warning disable [CSV list of numeric codes] Is there a list of these numeric codes and the description of the warning that they're suppressing? Much to my chagrin, I can't seem to locate it via Google. You shouldn't need a list. The compiler will tell you. If you get a compiler error that says "warning CS0168", then add 168 to the list (or, better yet, fix the code). MSDN has a list of warning codes. Unfortunately, you have to click each link to view what the code actually