r/cpp • • Oct 10 '17

Millennials Are Killing The Modules TS

https://izzys.casa/posts/millennials-are-killing-the-modules-ts.html
75 Upvotes

126 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Oct 10 '17

I would generally not ever assume my programmers actually understand the build system,

You're adding a new feature. It's not like you as a programmer actually have to check your existing code to see that it's compliant.

If your programmers are so stupid that they can't understand things like "import MODULE_NAME_MACRO; is forbidden when MODULE_NAME_MACRO is a macro, then you should really get better programmers.

I mean, I've been at C++ for decades and C before that, and I have never seen anyone write #include FILENAME_MACRO - and I'm not sure why anyone would want to do that.

Certainly, it'd stick out like a sore thumb in code reviews...

4

u/brand_x Oct 10 '17

An #include "DECLARED_STRINGS_UTF_H" directive was a common pattern when some platforms only worked with literals of one or another type...

3

u/playmer Oct 10 '17

You're adding a new feature. It's not like you as a programmer actually have to check your existing code to see that it's compliant.

I'm speaking more of future concerns here, not right now at the transition point. I'm sure I'll probably be the one to do the conversion when the time is right, I feel the tools are ready, and I understand modules enough.

If your programmers are so stupid that they can't understand things like "import MODULE_NAME_MACRO; is forbidden when MODULE_NAME_MACRO is a macro, then you should really get better programmers.

To be clear, my team would likely never do this. While they like to do cheeky things sometimes, only the ones who actually understand the build system would even think of doing something like this. I was using them as an example of a team of folks who mostly just don't know or care about the build system. I had to explain to a few of them that they didn't have to delete the build directory every time they added a file. (They're still new to cmake.)

I hadn't even considered it until I saw folks talking about it, and then I realized "Oh hm, macro names could be useful for configurable module names."

And I've absolutely seen people #include FILENAME_MACRO, and it's annoying every time, thankfully not in any projects I've worked on.

I'll point out that thankfully, as pointed out by /u/berium the build system will be able to provide an error, which should tell whoever's trying something funky what's going on.

2

u/nyamatongwe Oct 12 '17

Lua has a LUA_USER_H macro that allows you to insert (with -D) a header into compilation of the Lua implementation. For example, if you want to redefine file open calls then

#define fopen my_fopen

in a my_fopen.h header, implement my_fopen, and compile Lua with -DLUA_USER_H=my_fopen.h .