Compile Time Assertions in "C"
3 отговора
217 прегледа
Compile Time Assertions in "C"
Na [линк] predi godina imashe postnat tip za C++ compile time assertsions sus templates... eto i tuka edin variant na C.
Ideata tuka e da nakarame kompilatora da pokazhe po njakuw wid suobshtenieto koeto sme zadali, a ne samo che e wuzniknala greshka pri kompilatzia
To err is human
To stderr is inhuman
Ideata tuka e da nakarame kompilatora da pokazhe po njakuw wid suobshtenieto koeto sme zadali, a ne samo che e wuzniknala greshka pri kompilatzia
#define CASSERT(x) extern int CASSERTFAILED[1], CASSERTFAILED[(x)?1:2]
#define CASSERTMSG(x,msg) extern int CASSERTMSGFAILED_##msg[1], CASSERTMSGFAILED_##msg[(x)?1:2]
CASSERTMSG(sizeof(char)==2,char_must_be_2_bytes);
CASSERT(sizeof(long)==4);
CASSERTMSG(sizeof(short)!=sizeof(int),short_is_the_same_as_int);
To err is human
To stderr is inhuman
Re: Compile Time Assertions in "C"
heheh :-) hitro!
---
Bingo! Bongo! I don't want to leave the Kongo!
---
Bingo! Bongo! I don't want to leave the Kongo!
Re: Compile Time Assertions in "C"
Pochti sam siguren (99.99%) che sam wijdal neshto takowa v SDL.
W momenta sam wazprepyatstwan da prowerya, no da, hitro e.
W momenta sam wazprepyatstwan da prowerya, no da, hitro e.
Re: Compile Time Assertions in "C"
wuw windows.h sushto go ima - no realizatziata tam ne pechata nishto kato greshka, i raboti samo pod MSVC.
To err is human
To stderr is inhuman
To err is human
To stderr is inhuman