* ci: Fix compile warning as errors was not correct
We want to enable warning as errors both Windows and Linux. This is
easiest to do with cmake option as -Werror does not work with MSVC. Also
it is self explaining what it does so no comment needed.
* dlmstp_linux: Fix -Wdeclaration-after-statement compiler warnings
Make dlmstp_linux C89/C90 combatible
```
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘Timer_Silence’:
/bacnet-stack/ports/linux/dlmstp_linux.c:56:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
56 | int32_t res;
| ^~~~~~~
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘dlmstp_init’:
/bacnet-stack/ports/linux/dlmstp_linux.c:795:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
795 | struct termios newtio;
| ^~~~~~
```
* Fix warnings produces by MSVC
Now that we have enabled /Wall for MSVC we get some warnings with it
which can be easily fixed.
We get following warnings:
```
src\bacnet\bacstr.c(223,39): warning C4127: conditional expression is constant
apps\router-mstp\main.c(1123,1): warning C4702: unreachable code
apps\epics\main.c(885,53): warning C4459: declaration of 'myState' hides global declaration
```
* cmake: Use /Wall with MSVC
Make MSVC to build cleanly with Wall. This might matter for some Windows
developers. And you never know if MSVC will find more bugs.
* cmake: Improve router build
Router build gives some warnings as it is not C90 compatible. It is ok
that example is not following C90 rules. Also it is annoing to new user
to build this cmake as first error usually is that libconfig is not
found. Let's just give warning about this so first build will usually go
smoother.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
Win32 ports for BACnet
This directory contains a demo program that compiles with a Win32 compiler. It was tested with the free MinGW32 MSYS2 GCC compiler and the (free) Microsoft Visual Studio Community Edition
Building with Makefile under MinGW32
Note: Building for 64-bit with MinGW64 requires extra runtimes, whereas building for 32-bit as Win32 doesn't require any other files for the EXE to work in any version of Windows.
-
MSYS2 installation is (from powershell):
c:> winget install --id=MSYS2.MSYS2 -e
-
Start MSYS shell, and install MinGW32.
$ pacman -Syu mingw-w64-i686-toolchain
-
Edit ~/.bashrc file and add:
alias make=mingw32-make.exe
-
Exit MSYS.
-
Start MSYS profile for MinGW32.
-
Verify MSYS profile:
$ uname
MINGW32_NT-10.0-19045
-
Verify GCC is targeting i686:
$ gcc -dumpmachine
i686-w64-mingw32
-
Verify make is built for Windows32:
make --version
Built for Windows32
Building and running with Microsoft Visual Studio
- Obtain the (free) Microsoft Visual Studio Community Edition, or use your professional version. Currently tested to MSVC 2022
- Open solution file ports/win32/Microsoft Visual Studio/bacnet-stack.sln
- Set startup project to be the desired application project, e.g. "server"
- In the active project properties, debugging, set command line to desired DeviceID
- In active project properties, debugging, set environment variables as appropriate, e.g. BACNET_IFACE=10.59.2.1 BACNET_IP_PORT=53004
- Compile & run
- Questions? edward@bac-test.com