Questions tagged [pragma]
The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages.
754
questions
6
votes
1
answer
75
views
Why is gcc not ignoring comment as error when using #pragma GCC diagnostic ignored "-Wcomment"?
I have some comments that have some macro examples. To make them more readable, I end the line with a \ to continue the macro on the next line. I'd rather not put a space after the \ to remove the ...
0
votes
0
answers
13
views
GCC diagnostic ignored "-Wuninitialized" doesn't prevent build error
I am using GCC 12.1.0 with -Wall and -Werror enabled.
When building my code I want to ignore the following warning:
error: use of uninitialized value '' [CWE-457] [-Werror=analyzer-use-of-...
1
vote
2
answers
46
views
what does two __pragma inside a define macro means?
I am trying to understand one line of code having two __pragma operatores inside one define macro:
#define NULL (_Pragma("nomisrac 10.5") 0 _Pragma("nomisrac restore"))
I know ...
1
vote
2
answers
43
views
Suppressing warnings for a printf-like function in C++
I have a legacy logging printf-like function in C:
namespace legacy
{
void DoLog(const char* format,...);
}
If is only visible if a corresponding macro is defined (this is legacy too):
#ifdef LOG
...
2
votes
0
answers
45
views
How to undefine symbol for a C# project
I have a C# project defining a symbol named WIN:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants);WIN</...
-1
votes
1
answer
57
views
How to mark a code section with a warning purposely in C#?
is it possible to for example use #pragma to raise a custom warning within the VS IDE? I'd need it for a while because there are two classes in this code that contain the very same data but derive ...
1
vote
0
answers
71
views
I don't understand this mistake about #pragma
This is the first part of my code and I can't understand the mistake written at the end of the message. Maybe I don't know enough to understand it. I would be very grateful if someone can explain me ...
1
vote
1
answer
71
views
How do I fix this css prop horror show using emotion/twin.macro?
I am struggling to get my twin.macro setup working in my React app. I cannot provide an entire history of what I've tried, since I have tried dozens of different things, but I will outline my current ...
0
votes
0
answers
50
views
C open mp wrong calculation without print
#include<stdio.h>
#include<omp.h>
#include<stdlib.h>
float FloatRandomizer(float a, float b)
{
float randomNumber = (a + (float)rand() / (float)(RAND_MAX / b));
if (...
0
votes
1
answer
75
views
Testing a Flash Loan Smart Contract - Have some issues
I am making a smart contract as I'm still learning solidity and practicing. I wrote the code, and I am receiving this error on Remix:
contracts/flash.sol:8:1: ParserError: Expected pragma, import ...
0
votes
2
answers
70
views
Filtering vector onto another vector in Parallel
I'm trying to filter a vector into another vector in parallel. My current setup generates too much overhead so it's even slower than serial. Concretely:
#pragma omp parallel for collapse(2)
for(int i =...
0
votes
1
answer
40
views
Where to find C #pragma syntax parameters
Where to find C #pragma syntax parameters.
i can't find a specific description in compiler doc,and also in c99 manual
find #pragma helper for specify paltform, such as for aarch64 platform, C ...
0
votes
1
answer
78
views
How to best parallelize nested for loop that calls a variable update function?
I'm trying to parallelize a nested for loop in OpenMP (C++) that sort of looks like this:
for(i = 0 ; i < a.size() ; i++){
for(j = 0 ; j < a.size() ; j++){
if(i!=j)
a[i].update(...
0
votes
1
answer
27
views
How can I selectively disable warnings in different build targets using #pragma warning disable?
I have a solution which multi-targets net framework 4.8.1 and Net 6. The code needs to run on both Linux and Windows, so I need to bifurcate code with appropriate #if NET481 statements and this ...
0
votes
0
answers
20
views
Unknown pragma ignored: warning [duplicate]
I want to use #pragma warning:
#pragma warning(push, 0)
#include <geodesic.h>
#pragma warning(pop)
To disable all errors from third party libraries. However, the lines are being ignored:
...
1
vote
1
answer
96
views
Unable to implement Dijkstra's Algorithm using OpenMP in C
I am trying to parallelize Dijkstra using OpenMP, but the program is not working correctly. Sometimes the correct results are displayed while other times I get wrong values, I assume this is because ...
1
vote
0
answers
35
views
#pragma GCC unroll with compile-time argument
Is there a way to unroll a loop in GCC based on compile-time (e.g., template) parameter?
The following does not compile, unless I replace unroll(N) with a concrete integer like unroll(8)
template<...
0
votes
1
answer
25
views
In which object file will a function be defiined if it the function definition is within a class definition? [duplicate]
I found out that if you put the function defintion outside of the class, but within the .h file, a Linker error will be thrown as the function is already defined in the main.obj. That makes sense. So, ...
0
votes
1
answer
62
views
Pragma omp parallel for - more nested for loops
What is the best way to parallel more then two for (nested) loops inside some other for loop? So for examlpe there is four for loops inside another one
For{ for{...} for{...}for{...}for{...}}
When I ...
0
votes
1
answer
46
views
pragma pack(n) vs pragma pack(push,n)
What is the difference between
pragma pack(n) and pragma pack(push,n)
#pragma pack(pop) and #pragma pack()
Can someone explain through an example ? Which should be used when ?
I went through https://...
0
votes
1
answer
49
views
What is the effect of #pragma pack() when it follows a struct definition?
I have read other posts as well as the Microsoft Docs regarding the effect of #pragma pack(). I understand that it is useful when byte alignment is necessary.
However, I am still unsure of the effect ...
0
votes
0
answers
172
views
How to check if a column name exists in a SQlite database table (flutter)
I would like to know how can i check if a column name exists in a SQlite database table in Flutter. I am using this method, i would like to know if it is a good way to do it.
String table_name = '...
0
votes
0
answers
112
views
How to disable GCC warnings for multiple library files in Keil?
I know that you can write a #pragma directive at the beginning of the file to disable warnings, for example: #pragma GCC diagnostic ignored "-Wmissing-variable-declarations". But this ...
1
vote
1
answer
53
views
Nan behaves differently in #pragma cpp
I am learning about the NaN datatype, so, I ran a code to understand it and it goes well, the code worked as expected, but when I add a line #pragma GCC optimize("Ofast") in my code then, it ...
0
votes
1
answer
15
views
Declaring a variable/array in the specified location?
My aim is to port a #pragma define_section code to something that works on the GCC compiler( I have found out that some of the #pragma directives don't work on GCC compilers. Of course, my findings ...
1
vote
0
answers
32
views
How can I disable/enable a target attribute for the static initialization block in clang
I had an avx file that ended up with a static initialization block that contained avx code but shouldn't. In attempting to resolve the issue I tried marking the region with a pragma attribute:
https://...
0
votes
1
answer
37
views
Expand C preprocessor ternary macro for printing in pragma message?
Judging by this Print numeric value of a define that's based on other macros via pragma message? , what I want is likely not possible; then again, I'm not doing arithmetic here - so here is my ...
1
vote
0
answers
112
views
Disable compiler warnings with pragma GCC diagnostic in LTO builds
I'm having troubles disabling GCC warnings with LTO-enabled builds:
Some warnings (-Wstrict-overflow, -Wmaybe-uninitialized, ...) are
specified on the command line using the -W option switch for ...
1
vote
1
answer
84
views
Can my custom method satisfy Pragma Warnings?
For instance, when I do string.IsNullOrWhiteSpace(""), this satisfies the pragma warning:
CS8604: Possible null reference argument
Now, if I had defined an extension method called "&...
0
votes
0
answers
61
views
In SQLite, do attached databases take on, or inherit, the pragma settings of the main database?
In SQLite, do attached databases take on or inherit the "pragmatizations" of the "main" database? Or must I "pragmatize" each database, after an "ATTACH" ...
1
vote
1
answer
137
views
Is there any relation between pragma and predefined macros in C programming language, using GCC or any other compiler?
Recently I was asked if I know what pragma and macro is, and since I had used #pragma directive, I answered yes. But when I failed to implement a predefined macro (-Dsome_macro in gcc command ...
0
votes
1
answer
126
views
How to print defined macros with pragma to get OS version?
Following these related questions (1,2,3), I'm trying to get OS information from the preprocessor as follows:
#include <boost/preprocessor/stringize.hpp>
#ifdef __MACH__
#pragma message ("...
0
votes
2
answers
791
views
how to solve ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. in soliduty
i was pretty successful in running my auction code until maybe some keys were pressed and now this error started showing, I am unable to figure out why this error is showing
ParserError: Expected ...
3
votes
0
answers
126
views
Purpose of Pragma Inline in specification files
Many subprogram declarations of GNAT Standard Library uses Pragma Inline in their specification files and I want to know how it work because other modules use only this specification during ...
0
votes
0
answers
185
views
How to suppress warnings for a specific third-party header file's include in STM32CubeIDE (based on Eclipse)?
I was wondering if I can disable warnings for a particular header file's include in a STM32CubeIDE project? The compiler is gcc. I followed this recommendation and "guarded" a header with ...
0
votes
1
answer
295
views
use of undeclared identifier 'omp_get_thread_num()'
I was trying to train an SVM 1 vs all classifier with OpenCV(c++) in parallel manner since each class can be trained without waiting training of the other classes. While using #pragma omp parallel for ...
0
votes
1
answer
80
views
C++ omp for loop with conditional counter (not loop index, not a reduction)
I am parallelizing a code where elements of an array B are a function of elements of an array A. B is smaller than A (i know both sizes in advance) and B[n] is written only if A[n] satisfy a certain ...
0
votes
0
answers
143
views
Getting ParserError When trying to import ERC20Mintable
When I write
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract DaiTokenMock is ERC20{
The code compiles perfectly fine. However, I'm trying to import ERC20Mintable, in which ...
0
votes
0
answers
147
views
How to set SQLite Pragmas with Flyway/ Quarkus
I am trying to set up a Quarkus server that connects to a SQLite database in Java application. The database migration scripts are handled with Flyway.
Unfortunately I am not able to set Pragma ...
1
vote
1
answer
306
views
g++ complains of #pragma region if I use #pragma GCC diagnostic
I need to disable warning in an include file.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
<some function>
#pragma GCC diagnostic pop
however ...
-1
votes
2
answers
96
views
How do I implement this algorithm in C++ using OpenMP, or in which application can I implement it?
How do I implement Sum_EREW algorithm in C++ using OpenMP, or in which application can I implement it?
for i = 1 to log (n) do
forall j where 1 <= j <= n/2 do in parallel
if (2j ...
0
votes
2
answers
183
views
ParserError: Expected ';' but got 'event' -- solidity 0.8 address payable(msg.sender)
I don't know why I still get this error, I have already changed this address payable(msg.sender) to line 81 (I bold the line below) according to solidity 0.8 update, but it still gives an error. Can ...
4
votes
0
answers
100
views
Portable way of optimizing a single function or TU by a specific flag in both GCC and Clang
GCC provides two ways of optimizing a function or TU with a specific optimization flag:
[[gnu::optimize("-ffast-math")]]
void foo() { /* ... */ }
#pragma GCC optimize("ffast-math")...
0
votes
1
answer
71
views
Setting up OpenMp for a pattern that requires the value of a previous iteration
So I am having some trouble parellising my implementation of an algorithm that does some transformation on pixels in an image using OpenMP. A high level description is below in the form of the ...
4
votes
1
answer
379
views
How can I treat specific warnings as errors in C++ to be cross-platform?
I need to treat some specific warnings as errors to ensure the program runs as it is supposed to. For instance, functions with the [[nodiscard]] attribute should always return, otherwise the compiler ...
1
vote
1
answer
109
views
STM8 default EEPROM values COSMIC compiler
I'm developing a program using COSMIC 'C' compiler Ver 4.5.3 for STM8 CPU (STM8S003K3) and I want fill the MCU EEPROM with default values during mass production using ST-LINK/V2 device.
In the Manual ...
2
votes
1
answer
173
views
Is there a way to define a preprocessor macro that includes preprocessor directives?
There are a few loops I would like to direct the compiler to unroll with code like below. It is quite long and I'd rather not copy-paste.
Can #define statements define preprocessor macros?
I tried ...
0
votes
2
answers
183
views
Preprocessor pragma precedence with #if
I'm using the IAR Embedded Workbench compiler and have an issue with precedence of #pragma with #if.
I'm using #if 0 during development to comment out code.
The #pragma in the code below is to ...
0
votes
1
answer
944
views
Which address is paying the gas fee? And, can the smart contract pay the gas fee by itself?
pragma solidity ^0.8.1;
contract SendMoney{
uint public publicBalance;
uint public lockedUntil;
function receiveMoney() public payable{
publicBalance += msg.value;
...
0
votes
1
answer
955
views
How do I turn off warnings when compiling a kernel?
I'm trying to compile an android kernel using clang and I'm getting warnings that I don’t care about. For compilation I use the command make -j3 CC=clang O=output, so I cannot just add the -Wno-...