Advertisement · 728 × 90
#
Hashtag
#ifndef
Advertisement · 728 × 90
Post image

#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

0 0 0 0

#ifndef __LED_H //这是防止重复的语句,意思是if not define 如果没有定义,则执行该.h文件
#define __LED_H //上面一句如果确认如果Led.h确实没有被define,那么开始define

/*
函数函数函数
*/

#endif

0 0 0 0

ほんと、全然知らない、勉強不足を実感

ヘッダーファイルに

#ifndef _XX_H_
#define _XX_H_
……
#endif

と書いてインクルードガードとは。
なるほどねぇ

他人のソースを読むのは勉強になるなぁ

1 0 0 0

#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 …

2 0 0 0
Original post on social.mikutter.hachune.net

もしかして:/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 […]

0 0 1 0

they shouldnt have made #ifdef and #ifndef so similar looking.......

1 0 0 0

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.

2 0 0 0

inofitself reads like a fucked up C keyword or an architecture instruction. Literally #ifndef

1 0 0 0

#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

0 0 0 0

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?!

1 0 1 0
Preview
a man in a blue hoodie is holding a glass of beer and saying smart . ALT: a man in a blue hoodie is holding a glass of beer and saying smart .

#ifndef SAFE
#define SAFE
// Checkmate
#endif

0 0 0 0
Original post on social.mikutter.hachune.net

#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 */ […]

0 0 0 0
Preview
a person is feeding a hamster a piece of food on a table . Alt: a person is feeding a hamster a piece of food on a table while it's having Vietnam flashbacks

Me after seeing the classic

#ifndef X
#define X

... code

#endif

pattern

0 1 0 0

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

0 0 1 0

#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

2 0 2 0

I am surprisingly calm after finding out that the reason why the compiler kept telling me my new class was not a defined type was because I had a typo in my include guard.

I had written #ifdef instead of #ifndef so my header was not getting processed at all.

Surprisingly calm.

0 0 1 0

#include <stdio.h>
#include_next <twitter.h>
#ifdef __OBJC__
#import <objc/objc.h>
#endif
#pragma once
#ifndef Auschwitz
#define Auschwitz "Nazi concentration camp"
#endif
#if 1
#warning "foo"
#elif (1 != 1)
#error "bar"
#else
#endif
#line 1
#undef Auschwitz
#ident "ab"
#sccs "c"

0 0 1 0