Skip to content

build-sys: fix checking Windows platform with _WIN32 macro #3977

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

Merged
merged 1 commit into from
Apr 4, 2024
Merged

build-sys: fix checking Windows platform with _WIN32 macro #3977

merged 1 commit into from
Apr 4, 2024

Conversation

Biswa96
Copy link
Contributor

@Biswa96 Biswa96 commented Apr 3, 2024

This replaces WIN32 with _WIN32 macro to check Windows platform.
The correct one is _WIN32 as documented in the official documentation.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

@masatake
Copy link
Member

masatake commented Apr 3, 2024

I don't know Windows well. However, our own WIN32 is defined in mk_mingw.mak and mk_mvc.mak.
So I guess our WIN32 has nothing to do with _WIN32. Just replacing it may cause trouble.

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.39%. Comparing base (1223439) to head (6f1b290).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3977   +/-   ##
=======================================
  Coverage   85.39%   85.39%           
=======================================
  Files         235      235           
  Lines       56609    56609           
=======================================
  Hits        48339    48339           
  Misses       8270     8270           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leleliu008
Copy link
Member

@Biswa96 WIN32 is a user defined macro https://github.com/universal-ctags/ctags/blob/master/mk_mingw.mak#L10, _WIN32 is a predefined macro which is defined by MSVC or MINGW. what problem have you encountered?

@Biswa96
Copy link
Contributor Author

Biswa96 commented Apr 3, 2024

The issue was seen in geany project, here geany/geany#3660

WIN32 is a user defined macro

It is not required at all and contradicts with official and well-known _WIN32 macro.

@masatake
Copy link
Member

masatake commented Apr 3, 2024

Can we remove -DWIN32 from *.mak files?

@Biswa96
Copy link
Contributor Author

Biswa96 commented Apr 3, 2024

Can we remove -DWIN32 from *.mak files?

Yes, those can be removed also. I did not notice them at first.

@masatake
Copy link
Member

masatake commented Apr 3, 2024

Could you refer to geany/geany#3660 in the commit log?

@Biswa96
Copy link
Contributor Author

Biswa96 commented Apr 3, 2024

I have added the geany pull request link in commit message.

@Biswa96
Copy link
Contributor Author

Biswa96 commented Apr 3, 2024

Here are some example of the compiler and linker error in geany which are fixed by this change.

../ctags/gnu_regex/regex_internal.h:424:11: fatal error: alloca.h: No such file or directory
  424 | # include <alloca.h>
      |           ^~~~~~~~~~

../ctags/main/routines.c:463:21: warning: implicit declaration of function 'lstat'; did you mean 'wstat'? [-Wimplicit-function-declaration]
  463 |                 if (lstat (file.name, &status) != 0)
      |                     ^~~~~
      |                     wstat

ld.exe: libctags.a.p/ctags_main_routines.c.obj:routines.c:(.text+0x7cc): undefined reference to `lstat'

@masatake
Copy link
Member

masatake commented Apr 4, 2024

Can I ask you to change the prefix of the header of the commit log from "build.main,lex" to "build-sys" ?

build-sys: fix checking Windows platform with _WIN32 macro

This replaces WIN32 with _WIN32 macro to check Windows platform.
The correct one is _WIN32 as documented in the official documentation.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

This fixes the build issue with geany project, see the following thread
geany/geany#3660
@Biswa96 Biswa96 changed the title main,lex: Fix checking Windows platform with _WIN32 macro build-sys: fix checking Windows platform with _WIN32 macro Apr 4, 2024
@masatake
Copy link
Member

masatake commented Apr 4, 2024

@k-takata Thank you for reviewing.

@masatake masatake merged commit 0800593 into universal-ctags:master Apr 4, 2024
@Biswa96 Biswa96 deleted the fix-win32-macro branch April 4, 2024 12:57
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.

4 participants