-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
use MSVC preprocessor version when choosing macro versions in Tf's preprocessorUtilsLite.h #2990
use MSVC preprocessor version when choosing macro versions in Tf's preprocessorUtilsLite.h #2990
Conversation
Just noting that this seems similar to #2675 |
Ahh, it is indeed, thanks @nvmkuruc. I somehow missed seeing that one go by. The only difference between the two looks to be that I didn't change the use of Anyway, would be happy to see either #2675 or this find its way to being merged if they're agreeable to everyone. Thanks! |
That's correct!
Agreed! |
Filed as internal issue #USD-9393 |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
Hi Folks, was there ever any movement on this? I'm currently having to work around this issue in blender for Windows ARM64 builds, meaning I can't use sse2neon (which needs the new preprocessor) in any files which also include certain USD headers. |
e64a1cd
to
a510508
Compare
Freshening with a rebase on the current dev branch (35dbce1). |
When building with MSVC, one of two different versions of preprocessor may be in use. The older "traditional" preprocessor may in some cases treat macros differently versus other toolchains, particularly in cases that are officially undefined according to the language standard. In the past, this required specific versions of macros for MSVC. The newer, more standards-conforming preprocessor exhibits behavior much more closely aligned with other toolchains. This new preprocessor was available in experimental form as early as Visual Studio 2017 version 15.8, but it is considered feature complete as of Visual Studio 2019 version 16.5. The compiler option `/Zc:preprocessor` can be used to enable the new preprocessor. This change defines ARCH_PREPROCESSOR_MSVC_TRADITIONAL when MSVC's traditional preprocessor is being used. A subsequent change will make use of this definition in Tf's preprocessorUtilsLite.h when deciding which set of macros to use. See here for more detail about MSVC's preprocessors: https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview
… use in preprocessorUtilsLite.h In the cases where we were previously checking whether the compiler was MSVC when deciding whether to use an alternative set of macros versus other toolchains, what we really wanted to know was whether MSVC's "traditional" preprocessor was being used. This replaces the use of ARCH_COMPILER_MSVC in preprocessorUtilsLite.h with the newly added ARCH_PREPROCESSOR_MSVC_TRADITIONAL so that only in cases where we're compiling with MSVC *and* using its traditional preprocessor do we use the alternate macros. Otherwise when using MSVC's newer, more standards-conforming preprocessor, we use the same macros as other toolchains.
Hello!
When building with relatively recent versions of MSVC, one of two different versions of preprocessor may be in use. The older "traditional" preprocessor may in some cases treat macros differently versus other toolchains, particularly in cases that are officially undefined according to the language standard. In the past, this required specific versions of macros for MSVC. The newer, more standards-conforming preprocessor exhibits behavior much more closely aligned with other toolchains.
This new preprocessor was available in experimental form as early as Visual Studio 2017 version 15.8, but it is considered feature complete as of Visual Studio 2019 version 16.5. The compiler option
/Zc:preprocessor
can be used to enable the new preprocessor.Enabling the new preprocessor currently causes compilation of OpenUSD to fail however, since it does not handle the custom set of macros for MSVC the same way as the traditional preprocessor. Here is an example of the kind of errors and warnings that are emitted:
This patch was used to enable MSVC's new preprocessor:
The changes here define
ARCH_PREPROCESSOR_MSVC_TRADITIONAL
when building with MSVC using its traditionalpreprocessor. This then replaces the use of
ARCH_COMPILER_MSVC
inpreprocessorUtilsLite.h
so that only in cases where we'recompiling with MSVC and using its traditional preprocessor do we use the alternate macros. Otherwise when using MSVC's newer, more standards-conforming preprocessor, we use the same macros as other toolchains.
See here for more detail about MSVC's preprocessors:
https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview
I ran the unit tests for each of two separate builds with these changes in place, once without the patch above causing the traditional preprocessor to be used and again with the patch applied to enable the new preprocessor. All tests passed for both runs.