#pragma once and #ifndef do the same job. One is a compiler extension — widely supported but technically non-standard. The other is portable, verbose, and guaranteed by the spec.
Which you reach for says something about how you think about portability.
slashstar.store/blogs/code-c...
#cpp
#ifndef __LED_H //这是防止重复的语句,意思是if not define 如果没有定义,则执行该.h文件
#define __LED_H //上面一句如果确认如果Led.h确实没有被define,那么开始define
/*
函数函数函数
*/
#endif
ほんと、全然知らない、勉強不足を実感
ヘッダーファイルに
#ifndef _XX_H_
#define _XX_H_
……
#endif
と書いてインクルードガードとは。
なるほどねぇ
他人のソースを読むのは勉強になるなぁ
#ifndef _SHH_AVAILABILITY_H
#define _SHH_AVAILABILITY_H
#include <Availability.h>
#undef API_UNAVAILABLE
#define API_UNAVAILABLE(...)
#undef API_PROHIBITED
#define API_PROHIBITED(...)
#undef __API_UNAVAILABLE
#define __API_UNAVAILABLE(...)
#endif
clang -include ShhhAvailability.h …
もしかして:/usr/local/lib/X11/config/X11.tmplが腐ってる…?
#define XinitDir $(LIBDIR)/xinit
んでもって
#ifndef LibDir
# ifdef ProjectRoot
# define LibDir Concat(ProjectRoot,/lib/X11)
# else
# define LibDir /usr/lib/X11
# endif
#endif
この結果を受けて
LIBDIR = /usr/X11R6/lib/X11
XINITDIR = $(LIBDIR)/xinit
となるけど、実際は
ua […]
I already made a separate functions for lighter SH sampling. For example L0 sampling only which is enough for some toon shaders and mostly particles. Maybe it is a good idea to use some #ifndef blocking sections to make shader makers intentionally disable features. Not sure if it is a good idea.
inofitself reads like a fucked up C keyword or an architecture instruction. Literally #ifndef
#ifndef USE_SCRIPT
#define USE_SCRIPT
#endif
#ifndef USE_SML_M
#define USE_SML_M
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif
#ifndef USE_SCRIPT_JSON_EXPORT
#define USE_SCRIPT_JSON_EXPORT
#endif
#ifndef USE_SCRIPT_WEB_DISPLAY
#define USE_SCRIPT_WEB_DISPLAY
#endif
It's wild to me that #elifdef and #elifndef were not added to the C/C++-preprocessor standards until fucking *2023* when, I'm pretty sure that, #ifdef, #ifndef, and #elif have been included since before I was born. Like... it's such an obvious idea; why weren't they here sooner?!
#ifndef NOMEMCPY
if ((unsigned)w - d >= e)
/* (this test assumes unsigned comparison) */
{
putchar('[');fflush(stdout);
memcpy(redirSlide + (unsigned)w, redirSlide + d, e);
putchar(']');fflush(stdout);
w += e;
d += e;
}
else /* do it slowly to avoid memcpy() overlap */
#endif /* !NOMEMCPY */ […]
1. it's not #endif - if i remove #endif it's a different error message
2. it's not #if - if i replace it with #ifndef it has the same error message
3. it's not #define - the error does not go away if #define is not there
4. if there is no conditional it's perfectly fine
#pragma once
#ifndef POINT_H
#define POINT_H
#include <cmath>
#include <random>
class point
{
public:
point():point(.0,.0)
{
std::random_device rd;
std::mt19937 distr(rd());
std::uniform_int_distribution<int> prov(1, 20);
return prov(distr);
}
point(double x, double