Is there any reason not to use the INLINABLE pragma for a function?

There are three differences between using INLINABLE and not using a pragma at all: Without INLINABLE, the definition that goes in the interface file is the code after optimisation, whereas with INLINABLE, it is the code you wrote (more or less). In particular, without INLINABLE, GHC might inline other functions into the function’s definition. Without … Read more

What does #pragma once mean in C? [duplicate]

It’s used to replace the following preprocessor code: #ifndef _MYHEADER_H_ #define _MYHEADER_H_ … #endif A good convention is adding both to support legacy compilers (which is rare though): #pragma once #ifndef _MYHEADER_H_ #define _MYHEADER_H_ … #endif So if #pragma once fails the old method will still work. 2023 update I see some people in the … Read more

C++: What does #pragma comment(lib, “XXX”) actually do with “XXX”?

That pragma is used to link against the specified .lib file. This is an alternative to specifying the library in the external dependencies field in project settings. Mostly, it’s used to support different versions: #ifdef USE_FIRST_VERSION #pragma comment(lib, “vers1.lib”) #else #pragma comment(lib, “vers2.lib”) #endif When your application uses a dynamically-linked library, a lib file tells … Read more

C#: Is pragma warning restore needed?

If you do not restore the disabling is active for the remainder of the file. Interestingly this behaviour is not defined in the language specification. (see section 9.5.8) However the 9.5.1 section on Conditional compilation symbols does indicate this “until end of file behaviour” The symbol remains defined until a #undef directive for that same … Read more

Tell gcc to specifically unroll a loop

GCC gives you a few different ways of handling this: Use #pragma directives, like #pragma GCC optimize (“string”…), as seen in the GCC docs. Note that the pragma makes the optimizations global for the remaining functions. If you used #pragma push_options and pop_options macros cleverly, you could probably define this around just one function like … Read more

Pragmas in python

It is apparenly related to the coverage.py: Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not. That exact # pragma: no cover is the hint … Read more

Why isn’t #pragma once automatically assumed?

There are multiple related questions here: Why is #pragma once not automatically enforced? Because there are situations in which you want to include files more than once. Why would you want to include a file multiple times? Several reasons have been given in other answers (Boost.Preprocessor, X-Macros, including data files). I would like to add … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)