#746 closed Bug / Defect (fixed)

replace WIN32 with _WIN32

Reported by: cron2 Owned by:
Priority: major Milestone: beta 2.4
Component: Generic / unclassified Version: OpenVPN git master branch (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords:
Cc:

Description

the discussion around the c99 WIN32 breakage and patch brought up this URL regarding "how to reliably detect operating systems"

http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#WindowsCygwinnonPOSIXandMinGW

which recommends to use _WIN32, since that is always defined by the C compiler and not by some header file (windefs.h) which might or might not be included.

Basically this is just a big find and replace orgy, but the result wants to be tested.

Change History (4)

comment:1 Changed 15 months ago by selvanair

Alternatively have WIN32 defined in config.h or in $CPPFLAGS during configure. Easy to do as configure.ac already adds some Windows specific defines when mingw is in use. Then folks need not change their habit(?) of using #ifdef WIN32.

comment:2 Changed 15 months ago by cron2

config.h / configure would work, but then we're back to "if a file does not include config.h, it will not see the define" (plus, MSVC).

So _WIN32 sounds more failsave.

comment:3 Changed 13 months ago by cron2

Patch sent to list.

perl -pi -e 's/ WIN32/ _WIN32/; s/\(WIN32/(_WIN32/';" *.[ch]

auto-changed most of them easily...

Date: Thu, 10 Nov 2016 09:21:52 +0100
From: Gert Doering <gert@…>
To: openvpn-devel@…
Subject: [Openvpn-devel] [PATCH] Replace WIN32 by _WIN32

https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12987.html

comment:4 Changed 13 months ago by cron2

  • Resolution set to fixed
  • Status changed from new to closed

commit 445b192a7c31187c7b5c66c8250a1886b04a2b2c
Author: Gert Doering
Date: Sun Nov 13 20:52:28 2016 +0100

Replace WIN32 by _WIN32

Note: See TracTickets for help on using tickets.