Most active commenters
  • dboon(3)
  • CyberDildonics(3)

←back to thread

271 points mithcs | 14 comments | | HN request time: 0.202s | source | bottom
1. 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 #
2. Maxatar ◴[] No.45954109[source]
MSVC now supports C17.
replies(2): >>45954583 #>>45954706 #
3. 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.
4. atiedebee ◴[] No.45954583[source]
Does it support C99 with VLAs yet?
replies(1): >>45958557 #
5. 1718627440 ◴[] No.45954608[source]
You can use GCC on MS Windows just fine. Installing MSYS2 will also give you a package manager.
replies(1): >>45954941 #
6. CyberDildonics ◴[] No.45954706[source]
MSVC is also made out of a dozen javascript processes which makes typing text need a beefy computer.
replies(1): >>45955448 #
7. dboon ◴[] No.45954941[source]
Yes, of course. Unfortunately, sometimes you need to link to Windows binaries and therefore need to compile against the Windows ABI.
replies(1): >>45955341 #
8. 1718627440 ◴[] No.45955341{3}[source]
From https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html

> -mabi=name Generate code for the specified calling convention. [...] The default is to use the Microsoft ABI when targeting Microsoft Windows and the SysV ABI on all other systems.

> -mms-bitfields Enable/disable bit-field layout compatible with the native Microsoft Windows compiler. [...] This option is enabled by default for Microsoft Windows targets.

Doesn't this work in practice, due to bugs?

replies(1): >>45956199 #
9. electroly ◴[] No.45955448{3}[source]
MSVC is a C++ compiler toolchain and it does not contain any JavaScript. You're thinking of VSCode, probably, but your comment was an off-topic rant either way.
replies(1): >>45960539 #
10. electroly ◴[] No.45956199{4}[source]
(Not OP) The C++ ABI on Windows isn't compatible between g++ and MSVC, even though the C ABI is. Libraries using C linkage should work fine. MinGW-built programs link against the Microsoft C runtime (MSVCRT.DLL by default) which is itself MSVC-built, so linking MinGW programs to MSVC libraries has to work for anything to work.
11. hgs3 ◴[] No.45958557{3}[source]
It supports C99 minus VLAs. Worth noting that only C99 mandates VLAs. They are optional in C11, C17, and C23.
12. CyberDildonics ◴[] No.45960539{4}[source]
Microsoft visual studio the IDE (not vs code the electron program) has lots of javascript processes running in the background doing all sorts of things.

Also my comment was a single sentence with a single fact so it can't be a rant.

replies(1): >>46047169 #
13. dboon ◴[] No.46047169{5}[source]
MSVC is also completely different from Visual Studo. It’s OK to say you were wrong. You don’t have to be angry online. I promise!
replies(1): >>46049511 #
14. CyberDildonics ◴[] No.46049511{6}[source]
MSVC is also completely different from Visual Studo

It can and does refer to the IDE first. I'll prove it to your by showing that it's the first result of a search.

https://duckduckgo.com/?q=MSVC&t=ffab&ia=web

https://visualstudio.microsoft.com/vs/features/cplusplus/

It’s OK to say you were wrong. You don’t have to be angry online. I promise!

Seems like projection. Since it's ok to be wrong I guess you'll reply with an apology.