Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
0 answers
144 views

What is the "#pragma" directive in C++? [duplicate]

I was reading and came across the #pragma directive, so I decided to do some research. However, I didn't understand much and would like to see if someone can shortly explain it to me about the #pragma ...
Đỗ Quốc Khánh's user avatar
0 votes
1 answer
109 views

How do I tell gcc to shut up about forward declaring struct inside parameter list?

#pragma GCC diagnostic push #pragma GCC diagnostic ignore ??? int fstat(int handle, struct stat *statbuf); /* to get struct stat, #include <asm/stat.h> */ #pragma GCC diagnostic pop I've ...
Joshua's user avatar
  • 43.1k
-3 votes
0 answers
40 views

What is and use of pragma function in C [duplicate]

In C while doing file handling what is the use of pragma function. what if i don't use it? I was trying to make a problem set of harvard cs50 when i came across this. it needs to access bit file byte ...
Ziyankhan Pathan's user avatar
0 votes
2 answers
71 views

Is the C preprocessor part of the C standard?

I just know that #pragma once is not part of the C standard but rather part of the preprocessor. In that case, does that make the preprocessor not part of the C standard? So, are the C programming ...
jaroenchoke's user avatar
0 votes
1 answer
35 views

`pragma solidity` is giving error, even though I added the latest version

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract BankAccount { uint private balance; // Deposit function: adds an amount to the balance function deposit(uint amount) ...
JabirPapa's user avatar
0 votes
0 answers
23 views

What is the best way to implement file cacheing by different types?

The index page of website I'm working on sends 136 HTTP requests of which 105 are images, which I would like to have cached. The page currently has the meta tags cache-control no-cache and pragma no-...
user240174's user avatar
0 votes
0 answers
55 views

#pragma fenv_access (on) & #pragma STDC FENV_ACCESS ON

For the two pragmas #pragma fenv_access (on) #pragma STDC FENV_ACCESS ON Does it matter I put them before of after #include headers? Looks to me both are fine? Why GCC does not support "#pragma ...
JS0's user avatar
  • 1
0 votes
1 answer
33 views

clang compiler struct packing - always padded to 2bytes

clang compiler struct packing - always padded to 2bytes Short: I'm unable to get my clang compiler to pack the packed_struct_test test struct in lwip to 5 bytes. It always shows 6bytes. Details: Here'...
G. B.'s user avatar
  • 618
1 vote
1 answer
86 views

Test value of #pragma

In Xcode, I want to find out the value of the STDC FP_CONTRACT pragma after including just float.h and math.h. To my surprise, I couldn't find any way to do it! So the question: Am I just missing ...
gnasher729's user avatar
  • 52.5k
1 vote
0 answers
169 views

Setting GCC target options (AVX2) for static inline variables with a pragma doesn't work?

I'm using AVX2 instruction to initialize static inline variables in my code. But the following does not compile. #pragma GCC target("avx2") #include <iostream> #include <immintrin.h&...
Soumyadeep Dash's user avatar
2 votes
0 answers
97 views

In macro #define can we use #pragma push_macro and pop_macro

My goal is to remove name from SECTION_STOP in the following macros: // Start creates the object #define SECTION_START(name, ...) \ auto section_##name = create_section_name(#name, ## __VA_ARGS__); ...
Kron's user avatar
  • 143
-2 votes
2 answers
375 views

What does #pragma message do?

Using GCC on Linux (Mint) I have a line of code ... #pragma message "blah blah blah" When I run GCC I get this output with no warning, errors, etc ... src/source_file.c:29:9: note: ‘#...
IAbstract's user avatar
  • 19.9k
0 votes
1 answer
237 views

Disable XAML binding warning? #pragma warning disable XC0022

I am working w/ Maui XAML, but I would like to disable this XAML warning on a single file (ok maybe a few ;)). XamlC XC0022 warning : Binding could be compiled if x:DataType is specified. In C# I ...
kenny's user avatar
  • 22.3k
2 votes
2 answers
107 views

How to spawn a single thread with OpenMP (like a std::thread()) and use "#pragma omp single" and "#pragma omp for" afterwards?

I would simply like to spawn a background thread, like std::thread, but just with OpenMP. Is this possible? If yes, how ist it done? To better explain what I want to achieve, here the C++ Code of what ...
martin7743's user avatar
0 votes
0 answers
77 views

Borland C specify symbol name in function declaration

If I declare an external function in a C source file compiled with bcc32.exe (Borland C++ compiler, tested with the free version 5.5.1), it prepends an _ in the .obj file, for example, extern int ...
pts's user avatar
  • 87k
0 votes
0 answers
119 views

Should I use #pragma once directive in a hpp header, knowing well it contains some definitions? [duplicate]

I know there is use case scenario for '#pragma once' in classic .h headers containing only declarations. But I wonder: what about .hpp files which most of the time contain many definitions. Should I ...
LRetro's user avatar
  • 61
0 votes
1 answer
106 views

omp library c++ pragma for

I have this code, but I need help to use OpenMP #pragmas to increase its speed. I want to parallelize the for loops over variables i and j. The values of n and m can be much larger, too. For example,...
Vladimir Pugovkin's user avatar
3 votes
1 answer
117 views

Cpp20 non-strict char*

I've migrated our Visual Studio C++ project to Cpp20, and it's compiling fine except at a couple of places where some non-compliant library is called. The library defines macros like this: #define ...
digory doo's user avatar
  • 2,262
0 votes
2 answers
62 views

attribution of anonymous members during constant structure initialisation

Assume the following simple structure in C: struct entry { int id; const char *name; }; Nothing special. Say I'd like to initialise an array of members globally. One would do: const static ...
rralf's user avatar
  • 1,242
0 votes
1 answer
180 views

What is the equivalent in GCC to MSVC's '#pragma message'?

On MSVC I can issue compilation-time message like so: #pragma message("...some compilation-time message...") Is there an equivalent in GCC?
PazO's user avatar
  • 1,486
1 vote
0 answers
44 views

Is there a better way than passing /verbose to link.exe in order to see the effect of #pragma comment(lib, ...)?

#pragma comment(lib, ...) can be quite useful to declare library dependencies (static or import) from within a translation unit. As far as I am aware the way #pragma comment(lib, ...) works is by ...
0xC0000022L's user avatar
  • 21.3k
0 votes
1 answer
56 views

Increase speedup with OpenMP and reductions

I would increase speedup of these code with OpenMP. for (i = 1; i < length; i++) { for (j = 1; j < i; j++) sum_c += c[j]; c[i] = sum_c + W[i]; sum_c = 0; } I try with these ...
kilerin's user avatar
0 votes
2 answers
112 views

How to achieve RAII with #pragma's?

Currently, I have the following piece of code: enum class Letters { A, B, C }; #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wswitch" Letters e(Letters::A);...
neutrion's user avatar
0 votes
1 answer
85 views

How to pass no argument into pragma comment in c++

I want my program to show the console window if it detects the solution configuration is debug. If it detects release, then the console window should not show up #include "Window.h" int ...
Foryxled_Dev's user avatar
0 votes
1 answer
183 views

Visual Studio Stop Refactoring Away Using In Specific Area

Usually, I can disable an annoying warning by wrapping two pragma warning disable statements around it. For instance: #pragma warning disable IDE0060 public static int MultiplyByZero(int Number) =&...
Brendan Lynn's user avatar
4 votes
1 answer
639 views

Hashing function Sha256 in Circom

During the hackathon ETH Global Paris Was attempting to integrate a circom circuit with hashing a birthday date to prove that the user know the date following a well known medium tutorial. Here is its ...
Pavel Fedotov's user avatar
1 vote
1 answer
250 views

Is it possible to tell the compiler to only ignore specific unknown pragma?

I am not sure where I saw it first, but I got used to using #pragma region region name and #pragma endregion to mark sections in class definitions that belong together, like operator implementations. ...
Tomáš Zato's user avatar
  • 52.9k
0 votes
1 answer
154 views

C optimization with pragmas, does it recurse? Or does it simply use look at the order of the pragmas in the file?

Lets say we have project wide optimisation disabled (eg -O0) for my project and I did the following. Edit: I am using tricore-gcc (should be the same as normal GCC). There is no documentation I can ...
rollsch's user avatar
  • 2,760
1 vote
1 answer
950 views

Using pragmas efficiently in C++

I am a competitive programmer and I use pragmas for my codes. The pragmas that I use are: #pragma GCC optimize("O3") #pragma GCC optimization("Ofast,unroll-loops") #pragma GCC ...
MELTFREEZE's user avatar
0 votes
0 answers
273 views

GCC Pragma region error: expected expression before ‘#pragma’

I'm trying to fold elements in an array with #pragma region and #pragma endregion directives, but every time I compile it I get: gcc -ffreestanding -fshort-wchar -fno-stack-protector -Wall -Wno-...
somecollagist's user avatar
1 vote
1 answer
73 views

Are _Pragma operators allowed in the middle of function prototype declarations?

I've encountered some code like this: void _Pragma("function") f() { int i = 0; _Pragma("loop"); while (i < 100) { ... } } GCC compiles it without issues. But I don'...
anol's user avatar
  • 8,893
-1 votes
1 answer
97 views

Problem with outer loop vectorization using OpenMP in C

I am lerning how to use OpenMP to make a code use muttiple processors. Recently, I tried to make my Ewald Summation Fourier part parallel using OpenMP. Below is the function named ...
Seth's user avatar
  • 3
1 vote
1 answer
310 views

Avoiding warning 8-bit Ada Boolean return type, use Char

I have been working on cleaning up warnings on pedantic code, and we treat warnings as errors. I have interface code between Ada and C++, which looks like this: Ada manager.ads: function Foo(ID_Type : ...
Brinck's user avatar
  • 69
5 votes
1 answer
687 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 ...
Adrian's user avatar
  • 10.9k
2 votes
2 answers
215 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 ...
Zimo93's user avatar
  • 31
1 vote
2 answers
256 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 ...
DumbStudent2016's user avatar
2 votes
0 answers
198 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</...
Starnuto di topo's user avatar
-1 votes
1 answer
184 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 ...
CarstenP's user avatar
  • 241
1 vote
0 answers
170 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 ...
Ernestina Lede's user avatar
2 votes
1 answer
808 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 ...
serlingpa's user avatar
  • 12.6k
0 votes
0 answers
54 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 (...
Good guy from world's user avatar
0 votes
1 answer
505 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 ...
Alex's user avatar
  • 3
0 votes
2 answers
252 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 =...
pron1ghtmare360's user avatar
1 vote
1 answer
163 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 ...
Taoo's user avatar
  • 13
0 votes
1 answer
149 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(...
pron1ghtmare360's user avatar
0 votes
1 answer
262 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 ...
Isaac's user avatar
  • 344
1 vote
1 answer
251 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 ...
notbob's user avatar
  • 19
1 vote
0 answers
137 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<...
user2052436's user avatar
  • 4,745
0 votes
1 answer
173 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, ...
Chiara's user avatar
  • 1
0 votes
1 answer
116 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 ...
user779537's user avatar

1
2 3 4 5
16