Skip to content

Set /W4 through target_compile_options instead of a bogus define - #147

Merged
rouault merged 1 commit into
OSGeo:masterfrom
NathanGray-ChurchillNavigation:fix-clang-cl-dw4-define
Aug 11, 2026
Merged

rouault merged 1 commit into
OSGeo:masterfrom
NathanGray-ChurchillNavigation:fix-clang-cl-dw4-define

Conversation

@NathanGray-ChurchillNavigation

@NathanGray-ChurchillNavigation NathanGray-ChurchillNavigation commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

target_compile_definitions() prepends -D, so this line passed -D/DW4 and defined a macro named
/DW4. It never set the warning level - the neighbouring calls in the same block use -D spellings,
so /W4 as a compile option looks like what was meant.

MSVC tolerates the bogus name. clang-cl rejects it:

> clang-cl -c -D/DW4 t.c
<command line>(2,9): error: macro name must be an identifier

Moved to target_compile_options() so /W4 is applied as intended.

Verified with clang-cl 22.1.8: libgeotiff 1.7.4 builds clean at /W4, one warning across the 17
translation units (an unused parameter).

@rouault

rouault commented Aug 10, 2026

Copy link
Copy Markdown
Member

If the warning level is still wanted, target_compile_options(${GEOTIFF_LIBRARY_TARGET} PRIVATE /W4)
would be the equivalent - happy to change this to that instead if you prefer.

yes

target_compile_definitions() prepends -D, so this passed -D/DW4 and
defined a macro named "/DW4" rather than setting the warning level. MSVC
tolerates the bogus name; clang-cl rejects it with "error: macro name
must be an identifier".

Moving it to target_compile_options() applies /W4 as intended.
@NathanGray-ChurchillNavigation

Copy link
Copy Markdown
Contributor Author

Done - switched to target_compile_options(${GEOTIFF_LIBRARY_TARGET} PRIVATE /W4), so /W4 is actually applied now. Verified clang-cl accepts /W4.

@NathanGray-ChurchillNavigation NathanGray-ChurchillNavigation changed the title Remove bogus /DW4 compile definition Set /W4 through target_compile_options instead of a bogus define Aug 10, 2026
@rouault
rouault merged commit 75cfca5 into OSGeo:master Aug 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants