pragma

openMP conditional pragma “if else”

故事扮演 提交于 2019-12-05 01:21:54
I have a for loop that can be executed using schedule(static) or schedule(dynamic, 10) depending on a condition. Currently, My code is not DRY (Don't repeat yourself) enough and to accommodate the previous functionality it has the following repetition: boolean isDynamic; //can be true or false if(isDynamic){ #pragma omp parallel for num_threads(thread_count) default(shared) private(...) schedule(dynamic, 10) for(...){ //for code inside } }else{ #pragma omp parallel for num_threads(thread_count) default(shared) private(...) schedule(static) for(...){ //SAME for code inside, in fact, this is the

Update database version in Lua

旧时模样 提交于 2019-12-04 17:24:50
I'm trying to update the database version but, I'm facing a strange problem... Here's my code: version = 2 local cur_db_version=nil for data in db:nrows("PRAGMA user_version") do cur_db_version=data break end local db_version=cur_db_version.user_version print(db_version) print(version) if (db_version~=version) then create() db:exec("PRAGMA user_version="..version) end Imagining that the database version is 1 , I'm expecting that my script prints this: 1 2 But what it is printing is: 2 2 Why? I don't know but, I do know that if I comment the line db:exec("PRAGMA user_version="..version) , then

Finding the line number of a function in Haskell

孤人 提交于 2019-12-04 12:15:49
I am trying to create a Haskell program which draws some simple 2d shapes to screen, but when you hover over each shape, it prints the line of source code where the shape was created. In order to do this I would like to be able to create shapes with parameters for their dimensions and a final parameter which indicates the line number. Something like this: rect1 = Shape(Rectangle 2 2 lineNumber) This would create a rectangle of width 2 pixels, height 2 pixels, and use a function lineNumber to store the line this piece of code was written on. Does such a function exist in Haskell? Is it simple

Use #pragma pack with #define on Borland C++

无人久伴 提交于 2019-12-04 08:25:13
I am trying to pack some structs with Borland C++Builder (XE6) (in the future: bcc). I am using a library which uses the following construct to create structs: #ifdef _MSC_VER #define PACKED_BEGIN __pragma(pack(push, 1)) #define PACKED #define PACKED_END __pragma(pack(pop)) #elif defined(__GNUC__) #define PACKED_BEGIN #define PACKED __attribute__((__packed__)) #define PACKED_END #endif PACKED_BEGIN struct PACKED { short someSampleShort; char sampleByte; int sampleInteger; } structType_t; PACKED_END The bcc compiler does not like the MSC __pragma , and does not like preprocessor directives

What is the significance of #pragma marks? Why do we need #pragma marks?

巧了我就是萌 提交于 2019-12-04 07:20:43
问题 What is the purpose of #pragma marks in Xcode? Does their location in .m files matter? Should some #pragma come before all others? Do they have to be present? Can new marks be added? Why would they be? What causes it? Is there any harm in having a mark removed? Would one ever want to? 回答1: #pragma mark directives show up in Xcode in the menus for direct access to methods. They have no impact on the program at all. For example, using it with Xcode 4 will make those items appear directly in the

Why “pragma GCC diagnostic push” pop warning in GCC/C++?

随声附和 提交于 2019-12-04 06:18:06
#pragma GCC diagnostic push it pop: warning: expected [error|warning|ignored] after â#pragma GCC diagnosticâ Why? I use GCC in Linux. I have one question, if I can't use pop/push, if the ignore only influence the compiled cpp, not influence other cpp? if some other include the cap, if influence it? #pragma GCC diagnostic push and #pragma GCC diagnostic pop were added in gcc 4.6 . You're using an older version. These pragmas are typically used in conjunction with other #pragma GCC diagnostic directives to suppress, turn on, or turn into an error specific warnings for a small section of your

Are there any preprocessor directives that control loop unrolling?

折月煮酒 提交于 2019-12-04 05:39:18
Furthermore, how does the compiler determine the extent to unroll a loop, assuming all operations in the loop are completely independent of other iterations. For MSVC there is only a vector independence hint: http://msdn.microsoft.com/en-us/library/hh923901.aspx #pragma loop( ivdep ) For many other compilers, like Intel / ibm , there a several pragma hints for optimizing a loop: #pragma unroll #pragma loop count N #pragma ivdep There is a thread with MSVC++ people about unroll heuristic: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/d0b225c2-f5b0-4bb9-ac6a-4d4f61f7cb17/ VC

When to use pragmas on sqlite?

耗尽温柔 提交于 2019-12-04 04:19:49
When the pragmas are used? When the database is created for first time or in each connection to database? this depends on the pragma being used. from The definitive guide to SQLite , Database Configuration : Many pragmas have both temporary and permanent forms. Temporary forms affect only the current session for the duration of its lifetime. The permanent forms are stored in the database and affect every session. or, in the words of your question: Temporary forms are used in each connection to database, permanent forms are used when the database is created for the first time . the pragma

#pragma init and #pragma fini using gcc compiler on linux

最后都变了- 提交于 2019-12-04 01:49:21
I would like to build some code which calls some code on loadup of the shared library. I thought i would do it like this: #pragma init(my_init) static void my_init () { //do-something } int add (int a,int b) { return a+b; } So when i build that code with gcc -fPIC -g -c -Wall tt.c It returns gcc -fPIC -g -c -Wall tt.c tt.c:2: warning: ignoring #pragma init tt.c:4: warning: ‘my_init’ defined but not used So its ignoring my #pragmas. I tried this in real code and my code aborted because a function hadn't been called in the pragma section because it was ignored. How do i get gcc to use these

How do I define a macro with multiple pragmas for Clang?

寵の児 提交于 2019-12-04 00:12:07
I'd like to add some macros to ease (un)setting a specific warning around routines that we are deprecating internally. I'd like to turn this: #pragma clang diagnostic push #pragma clang diagnostic warning "-Wdeprecated-declarations" void Foo() __attribute__((deprecated("Warning: deprecated routine"))) #pragma clang diagnostic pop into this: MY_DEPRECATED_BEGIN void Foo() MY_DEPRECATED MY_DEPRECATED_END The MY_DEPRECATED_BEGIN macro is giving me trouble as I have to specify two pragmas in a single macro. Can this be done? (Bonus points for a solution that achieves the same effect using only the