whitequark,
@whitequark@mastodon.social avatar

<stdio.h>
struct x{};
int main() { printf("%d\n", sizeof(struct x)); }

clang test.c && ./a.out # prints 0
clang++ test.cc && ./a.out # prints 1

someone kill me

chandlerc,
@chandlerc@hachyderm.io avatar

@whitequark that's not what frustrates me...

What gets me is that I suspect this can't be changed because a bunch of things use this to detect whether the compiler is C or C++. =[[[[[

whitequark,
@whitequark@mastodon.social avatar

@chandlerc I was trying to make sure a C++ class with a parametric size has a C-compatible layout with a static assert...

Rairii,
@Rairii@haqueers.com avatar

@whitequark i've come across this before

i think for c++ i used a zero-sized array (which may or may not be a gnu-ism i can't remember)...

cwiek,
@cwiek@mastodon.social avatar

@whitequark
cc -W -Wall -Werror -pedantic -pedantic-errors st.c -o st
prog.c:3:8: error: struct has no members [-Wpedantic]
3 | struct x{};
| ^
make: *** [/home/user/Makefile:9: st] Błąd 1

jacqueline,
@jacqueline@chaos.social avatar

@whitequark what are the boffins at clang++ hq hiding in there…

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines