Skip to content

Commit

Permalink
Support __linux__ and __APPLE__ in --cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Jan 26, 2024
1 parent 6712771 commit 2705779
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lfortran/parser/preprocessor.re
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ CPreprocessor::CPreprocessor(CompilerOptions &compiler_options)
if (compiler_options.platform == Platform::Windows) {
md.expansion = "1";
macro_definitions["_WIN32"] = md;
} else if (compiler_options.platform == Platform::macOS_ARM
|| compiler_options.platform == Platform::macOS_Intel) {
md.expansion = "1";
macro_definitions["__APPLE__"] = md;
if (compiler_options.platform == Platform::macOS_ARM) {
md.expansion = "1";
macro_definitions["__aarch64__"] = md;
} else {
md.expansion = "1";
macro_definitions["__x86_64__"] = md;
}
} else if (compiler_options.platform == Platform::FreeBSD) {
md.expansion = "1";
macro_definitions["__FreeBSD__"] = md;
} else if (compiler_options.platform == Platform::OpenBSD) {
md.expansion = "1";
macro_definitions["__OpenBSD__"] = md;
} else {
md.expansion = "1";
macro_definitions["__linux__"] = md;
}
for (auto &d : compiler_options.c_preprocessor_defines) {
std::size_t idx = d.find("=");
Expand Down

0 comments on commit 2705779

Please sign in to comment.