Skip to content
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

Improve handling of -std options #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions cccl
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,44 @@ EOF
;;

-std=*)
clopt+=("${slash}std:${1:5}")
case "$1" in
-std=c++*)
-std=c++98|-std=c++03|-std=c++11)
# "Note that the MSVC compiler does not, and never will, support a
# C++11, C++03, or C++98 standards version switch."
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
#
# We can at least turn off permissive mode.
clopt+=("${slash}permissive-")
;;

-std=gnu++98|-std=gnu++03|-std=gnu++11)
# Similar to above, but leave permissive mode on.
;;

-std=c89|-std=c90|-std=c99)
# MSVC only documents accepting /std=c11 and upwards.
#
# We can at least turn off permissive mode.
clopt+=("${slash}permissive-")
;;

-std=gnu89|-std=gnu90|-std=gnu99)
# Similar to above, but leave permissive mode on.
;;

*)
clopt+=("${slash}std:${1:5}")
;;
esac

case "$1" in
-std=c++*|-std=gnu++*)
# This is needed to get MSVC to define __cplusplus to the correct
# value, but is only supported by Visual Studio 2017 version 15.7
# and later. Earlier versions will emit a warning but it's hard
# to see how to avoid this:
#
# cl : Command line warning D9002 : ignoring unknown option '/Zc:__cplusplus'
clopt+=("${slash}Zc:__cplusplus")
;;
esac
Expand Down