787 questions
Advice
0
votes
2
replies
85
views
Utilizing GSL for Intel C++ on Windows without implementing lib flags or pragma or CMake
Using vcpkg on Windows 11, I installed GSL (GNU Scientific Library) with vcpkg install gsl.
Then I did
set INCLUDE=E:\<mypath>\vcpkg\installed\x64-windows\include;%INCLUDE%
set LIB=E:\<mypath&...
4
votes
0
answers
160
views
How to properly use MSVC's undocumented #pragma extern_absolute with functions?
I am looking for information about the following preprocessor #pragma directive:
#include <string>
class Base {
public:
void Test();
};
int main() {
Base b;
b.Test();
return 0;
...
2
votes
1
answer
87
views
Disable Perl warnings for call to remote function
I'm defining some tests for a library I'm using. One of my tests is calling the code in such a way that it produces warnings, which is expected. However, I'd ideally like to suppress these warnings ...
2
votes
3
answers
110
views
Open-MP Parallel for (three-dimensional array)
We are working with the following code:
int i, j, k;
for (i = 2; i < n; i++){ // S1
for (j = 3; j < n - 3; j++){ // S2
for (k = 4; k < n - 4; k++){ // S3
A[...
0
votes
1
answer
63
views
How can I pad the bytes in a section defined by a pragma directive?
So I have these two macros
#define ESTART \
_Pragma("optimize(\"\", off)") \
_Pragma("section(\".secure\", execute, read, write)") \
_Pragma("...
1
vote
1
answer
53
views
sqlalchemy insert PRAGMA statement while dealing with postgresql database
I'm trying to migrate a small table on local SQLite database to a remote postgresql server, but I'm getting error message "(psycopg2.errors.SyntaxError) syntax error at or near "PRAGMA" ...
1
vote
1
answer
63
views
The equivalent of list initialization but with narrowing conversion
I want to provide a function to convert parameters, which are read as long long or long double from XML, to any type constructible from these types with narrowing conversion. But I want to use list ...
0
votes
1
answer
44
views
Does pragma comment link same library multiple times if same comment is written multiple times?
In visual studio, does pragma comment link same library multiple times if written multiple times? Or comments second onwards ignored? I've checked comment but it doesn't seem to be clearly stated.
0
votes
0
answers
53
views
Why HLS C++ code generates non specified input?
I'm learning the basics of High-Level Synthesis (HLS) using AMD/Xilinx tools. Most courses use older tools for the practical examples (Vivado HLS instead of Vitis 2024.2 which I'm using).
This is the ...
1
vote
1
answer
178
views
Pragma is added to header even though I removed it from the code
As per security recommendations, I have removed Pragma settings from our site (Angular JS and ASP.Net), however, I still see it in the response headers, could be that the framework is adding it by ...
2
votes
1
answer
153
views
issues interleaving `#pragma` and `__attribute__` on GCC
Background
Note: This is not important for the question
I have some macros that act as slightly more general version of attributes, that I attach to functions. Depending on the compiler and compiler ...
1
vote
1
answer
88
views
Does 'use warnings' change $^W?
I've been using Getopt::Long and at one point in the code, where I think it should warn(), it doesn't, unless I run with -w.
Upon inspection, the (Getopt::Long) code directly checks the value of $^W. ...
0
votes
1
answer
132
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 ...
1
vote
2
answers
100
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 ...
1
vote
1
answer
59
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) ...
0
votes
0
answers
122
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 ...
0
votes
1
answer
74
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'...
1
vote
1
answer
99
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 ...
1
vote
0
answers
415
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&...
2
votes
0
answers
133
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__);
...
-2
votes
2
answers
2k
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: ‘#...
0
votes
1
answer
931
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 ...
2
votes
2
answers
195
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 ...
0
votes
0
answers
106
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 ...
0
votes
0
answers
257
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 ...
0
votes
1
answer
144
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,...
3
votes
1
answer
131
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 ...
0
votes
2
answers
63
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 ...
0
votes
1
answer
308
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?
1
vote
0
answers
66
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 ...
0
votes
1
answer
60
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 ...
0
votes
2
answers
118
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);...
0
votes
1
answer
91
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 ...
0
votes
1
answer
242
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)
=&...
4
votes
1
answer
844
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 ...
1
vote
1
answer
379
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.
...
0
votes
1
answer
354
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 ...
1
vote
1
answer
2k
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 ...
1
vote
0
answers
401
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-...
1
vote
1
answer
137
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'...
-1
votes
1
answer
105
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 ...
1
vote
1
answer
390
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 : ...
5
votes
1
answer
1k
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 ...
2
votes
2
answers
292
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
361
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
236
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
219
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
233
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 ...
2
votes
1
answer
892
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
55
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 (...