←back to thread

271 points mithcs | 1 comments | | HN request time: 0s | source
Show context
dboon ◴[] No.45954041[source]
Nice, but if the intention is portability my experience has unfortunately been that you pretty much have to stick to C99. MSVC’s C compiler is rough, but pretty much necessary for actual cross platform. I have my own such header which has many, many things like the OP’s. As much as I would find it constantly useful, I don’t have a cleanup utility because of this.

But if you can stay out of MSVC world, awesome! You can do so much with a few preprocessor blocks in a header

replies(3): >>45954109 #>>45954162 #>>45954608 #
1. Dwedit ◴[] No.45954162[source]
That's the nice thing about macros, you can also have the macro generate C++ code using destructors instead of using the cleanup attribute. As long as your other C code is also valid C++ code, it should work.