cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[QUESTION] how would we handle cross platform abstractions with out macros?

Open pheonixfirewingz opened this issue 2 years ago • 1 comments
trafficstars

Hay I'm I love the new syntax for c++2 but how would we handle cross platform without the pre-processor. For example #if WIN32 > use this, and #if LINUX > use this. Without a mechanism like the pre-processor this would as far as I'm aware make it impossible to write cross platform code. unless there is a newer c++ 20/23/... feature I don't know about? What could be implemented into CPP2 to cater for this area of development projects?

pheonixfirewingz avatar Nov 24 '22 14:11 pheonixfirewingz

Those defines are defined somewhere in files, either generated by the compiler, shipped with it, or set as arguments to the compile call. All of these cases can use constexpr constants, allowing you to write if constexpr statements in your code for cross platform compatibility.

I believe Herb has also mentioned that he wants expressions to be writable in global scope, allowing such constant evaluated ifs to block out global definitions etc

On 24 November 2022 14:12:35 Luke Shore @.***> wrote:

Hay I'm I love the new syntax for c++2 but how would we handle cross platform without the pre-processor. For example #if WIN32 > use this, and #if LINUX > use this. Without a mechanism like the pre-processor this would as far as I'm aware make it impossible to write cross platform code. unless there is a newer c++ 20/23/... feature I don't know about? What could be implemented into CPP2 to cater for this area of development projects?

— Reply to this email directly, view it on GitHubhttps://github.com/hsutter/cppfront/issues/136, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AALUZQJ6STE56HTTF3AQMZDWJ5ZVBANCNFSM6AAAAAASKOGL74. You are receiving this because you are subscribed to this thread.Message ID: @.***>

SebastianTroy avatar Nov 24 '22 14:11 SebastianTroy

@pheonixfirewingz Good question. Further along the lines @SebastianTroy mentioned, my aim is to embrace reflection and generation, the latter meaning generative programming equivalent to (disciplined) source code generation that is part of the language, not a preprocessor outside the language.

I've now added a new design note for this:

Thanks for the question!

hsutter avatar Nov 25 '22 18:11 hsutter