New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support APPLE
and LINUX
platforms in CPP Preprocessing
#3229
Support APPLE
and LINUX
platforms in CPP Preprocessing
#3229
Conversation
Output of the added test on MacOS: % lfortran integration_tests/cpp_pre_03.f90 --cpp
OSX
Ok |
Also see #3217 (comment). |
592b487
to
9ff47ac
Compare
} else if (compiler_options.platform == Platform::macOS_ARM | ||
|| compiler_options.platform == Platform::macOS_Intel) { | ||
md.expansion = "1"; | ||
macro_definitions["__APPLE__"] = md; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add other C++ defines, here is our relevant code:
Platform get_platform()
{
#if defined(_WIN32)
return Platform::Windows;
#elif defined(__APPLE__)
# ifdef __aarch64__
return Platform::macOS_ARM;
# else
return Platform::macOS_Intel;
# endif
#elif defined(__FreeBSD__)
return Platform::FreeBSD;
#elif defined(__OpenBSD__)
return Platform::OpenBSD;
#else
return Platform::Linux;
#endif
}
So let's add:
__FreeBSD__
__OpenBSD__
and also platform defines:
__aarch64__
__x86_64__
That should cover most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Added.
% cat integration_tests/cpp_pre_03.f90
program cpp_pre_03
#ifdef _WIN32
print *,"Windows"
#endif
#ifdef __linux__
print *,"Linux"
#endif
#ifdef __APPLE__
print *,"OSX"
#endif
#ifdef __aarch64__
print *,"Apple ARM"
#endif
#ifdef __x86_64__
print *,"Apple AMD"
#endif
#ifdef __FreeBSD__
print *,"FreeBSD"
#endif
#ifdef __OpenBSD__
print *,"OpenBSD"
#endif
print *, "Ok"
end program
% gfortran integration_tests/cpp_pre_03.f90 -cpp
% ./a.out
Ok
% lfortran integration_tests/cpp_pre_03.f90 --cpp
OSX
Apple ARM
Ok
9ff47ac
to
b9250f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is good. We'll have to eventually revamp how we handle the architecture / platform "triplet", since linux can also be "arm", and so on. But for now this is good to get us started.
Thanks!
macro_definitions["__aarch64__"] = md; | ||
} else { | ||
md.expansion = "1"; | ||
macro_definitions["__x86_64__"] = md; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to define this on Linux.
fixes #3217