les chefs de projets à la con, en c++ /c avec du code à conserver au cas où : lui pourquoi t'as pas mis en /* , bin parce qu'il y a déjà des commentaires en /* et que ça va être chiant à dé commenter ,
#IF 0
//code mort yyyymmdd
#ENDIF
je n'aime pas ça, les dev "oui mais c'est connu,andouille"
Geez, Apple. Get your house in order.
```swift
#if targetEnvironment(simulator)
import Foundation
#else
#if os(macOS)
@preconcurrency import NetworkExtension
#else
import NetworkExtension
#endif
#endif
```
#ifndef __LED_H //这是防止重复的语句,意思是if not define 如果没有定义,则执行该.h文件
#define __LED_H //上面一句如果确认如果Led.h确实没有被define,那么开始define
/*
函数函数函数
*/
#endif
#endif
😅
Jo. Wer weiß. Oder Mandarin.
Improved the .#if ... .#else ... .#endif syntax for case configuration files in #OpenFOAM-dev github.com/OpenFOAM/OpenFOAM...
ほんと、全然知らない、勉強不足を実感
ヘッダーファイルに
#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 …
I tend to leave potentially useful code inside #if #endif so I can switch it back in easily if it is multiple lines. Then, many days later I can have a tidy up and remove the unrequired lumps once I am pretty sure everything is working. Fine for a single-programmer project, not good for a team.
huh, I thought ublock origin rules could be parsed line-by-line, but turns out they can't be
bc you can have if directives in them, like
!#if env_mobile
example.com##.my-mobile-class
!#else
example.com##.my-desktop-class
!#endif
TIL
もしかして:/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 […]
Still always making strange code
#if 0
#pysea.c
#polyglot-file
import sys
print ('Hello, world - Python\ngcc -o pysea', sys.argv[0])
#endif
#include <stdio.h>
#define exit int main(int argc, char** argv)
#define quit { printf ("Hello, world - C.\npython3 %s.c\n", argv[0]); return 0; }
exit
quit
#Swift folks (especially @mattiem ):
With Swift 6.2’s new concurrency checking/rejecting on Actor’s `static var …`, is it safe-enough to do something like this for dependency injection?
```swift
struct Config {
nonisolated(unsafe) private static var _shared: Self = .init()
#if TESTING
static […]
#if defined(__alpha__) && defined(CONFIG_PCI)
/*
* The meaning of life, the universe, and everything. Plus
* this makes the year come out right.
*/
year -= 42;
#endif
-- From the patch for 1.3.2: (kernel/time.c), submitted by Marcus Meissner
I frequently typo
#endif
as
3endif
But it's the first time I came up with
#3ndif
as if my brain considered creating a variant
You can use “#if compiler(>=6.2)” as an alternative. That checks if the Xcode has Swift 6.2 which works with any Xcode version. So:
#if compiler(>=6.2)
some new iOS 26 api
#else
Fallback if needed
#endif
A code screenshot from Xcode where this conditional has a drop down menu at its corresponding #endif that offers to insert a conditional comment. #if DEBUG && true
First thing I notice when I launched Xcode 26 is that it's indicating what an #endif is associated with and offering to insert a conditional comment.
Very nice!
What's intriguing there is using conditional compilation (#define, #ifdef, etc.) to build C++ classes that include BOTH sets of platform-specific calls in the same methods:
#ifdef ANDROID
/* Speak Android JNI natively */
#endif
#ifdef IOS
/* Speak Objective C++ natively */
#endif
Nice straight forward technique.
Putting the option for each compiler into an `#ifdef` block would make it a library option
```
#ifdef __GNUC__
asm_macro def
#else
vs_native_macro def
#endif
```
#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
Crash at line 9.
Line 9: #endif
Package traits SE-0450:
1. Define a trait as an arbitrary token. e.g. "Firebase"
2. Add Firebase as optional dependency when that trait is enabled
3. Conditionally compile
#if Firebase
import Firebase
...
#endif
4. A client of your package can enable "Firebase" to add related code and libraries.
I have my test thing being a separate executable whose entire purpose is... running each of the tests.
(I also put the tests inside an #if … #endif block so the tests only get compiled if building a debug build.)
Oof. I don't think I see a way for constexpr class instances to auto-register in C++17 (hash <-> c_str); I mean, it's a side-effect.
constexpr H foo("foo");
int main() {
std::print("foo hash = {0}\n", foo.val());
#ifdef _DEBUG
std::print("foo str = {0}\n", Hashed::lookup(foo.val()));
#endif
}