#ifndef — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #ifndef, aggregated by home.social.
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
@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"
YoIs 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.
-
@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"
YoIs 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.
-
@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"
YoIs 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.
-
@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"
YoIs 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.
-
@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"
YoIs 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.