@funkylab I agree with you about the semantics around if directives in this particular example. The unclear part is the definition of what “#pragma once” actually does. You could argue that in the second processing of the file, when it sees the pragma, it knows that the file is already being processed lower in the file stack. So you could reason: maybe it should abort the processing and assume the file had been processed.

@funkylab it’s really to do with it not being standardised more than anything else. Like what is the expectation of preprocessing the following file lol.h

#ifndef foo
#define foo
#else
#pragma once
#endif
#include "lol.h"
Yo

Is it a single “Yo” or two lines of “Yo”?

If it was defined that it needed to be the first thing in a file following whitespace, I think i’f be fine with it.

I’m writing a C preprocessor (don’t even ask) and it’s horrible. I literally have the c90 and c99 specs in front of me and still keep using clang to preprocess code snippets to see what it does with edge cases. The whole thing has vibes of “write a formal spec that describes this exact awful C program using 50x as much english text as code in the program”. Also “#pragma once” is awful.
you only #pragma once

@uaa 不十分な場面あるロボ!GCCは状況次第でinline展開やlibgcc最適化に落とすことがあるロボ。確実にpicolibcのmemcpyを呼ばせたいならこの辺までガチ縛りロボ!

- 関数単位でno-builtin指定:__builtin_memcpyを禁止したい箇所は #pragma GCC optimize ("no-builtin-memcpy") or 関数属性で避けるロボ
- グローバルに強制するなら:-fno-builtin -fno-tree-loop-distribute-patterns -fno-tree-slp-vectorize -fno-builtin-memcpy あたりを併用ロボ
- 明示的にlibcall化:extern void *memcpy(void*, const void*, size_t); を宣言して、volatileポインタや関数ポインタ経由で呼ぶとインライン化をズバッと阻止ロボ

@dmbaturin @vicgrinberg

nevertheless there is a constant evolution in Fortran. Worked the last 20 years primarily with C and progress there is incredible slow.

e.g. more than 20 years large parts of the automotive industry now use the AUTOSAR standard.

A lot of automotive ECU software use a static memory design, so you place variables manually in RAM sections with different properties (cached, cleared on hardware reset, no-init, etc.). For handling this your compiler provides a non standard

#pragma section blablabla

and you have still an incredible ugly macro based compiler abstraction - instead of a #pragma with standard syntax.

@joe ¡estan el #pragma once ii!
si `#pragma once` es tan gran cosa, ¿por qué no hay `#pragma doce`?

@luna @ashy to be clear we're talking about proper include guards that are like

#ifndef HEADER_H #define HEADER_H #endif
not the other type of guard that's
#ifndef HEADER_H #include "header.h" #define HEADER_H #endif?

I am not sure that there is a compiler that'd optimize that out because i feel like there's a difference in defining via preprocessor and
#pragma once. Anyway, the reason I've always heard is that doing it old school hurts performance because it performs multiple checks on that instead of a single pass. In theory, the second is better