r/cpp • • Aug 08 '20

Create a fully functioning command line interface with 1.5 lines of code (wo. include statement)

https://github.com/kongaskristjan/fire-hpp
230 Upvotes

62 comments sorted by

View all comments

1

u/F54280 Aug 08 '20 edited Aug 08 '20

Why using a #define in 2020?

edit: this snarky remark was about the FIRE macro

11

u/kongaskristjan Aug 08 '20

Though having it's perks, #pragma once is non-standard according to wikipedia.

1

u/BobFloss Aug 08 '20

Every compiler supports it.

19

u/kongaskristjan Aug 08 '20

Well, I'm actually OK with using non-standard stuff, if it's really supported everywhere, but this is a library that is meant to be plug and play for everyone, including people who want to comply with the standard strictly.

It's quite similar to the reason why I test against maximum compiler warnings on various compilers - I don't know what the user needs to comply with.

6

u/[deleted] Aug 08 '20

I have heard this argument for over a decade.

No one ever actually shows me a compiler without #pragma once.

:-D

10

u/encyclopedist Aug 08 '20

Obviously, you did not really try to find one. TI compilers did not support it last I checked. PGI did not support in either. Also Cray. And XLC.

There was a topic in this very reddit some time ago: https://www.reddit.com/r/cpp/comments/8devw1/can_anyone_actually_name_a_compiler_that_doesnt/

3

u/jbandela Aug 08 '20

I think basically every compiler that supports generic lambdas supports pragma once

6

u/rsjaffe Aug 08 '20

But #pragma once fails when you have two copies of the same header file in two different locations in the directory tree. The compiler will not recognize those two files as being the same.

7

u/panderingPenguin Aug 08 '20

Why on earth would you want to do that?