Error when building FLTK-1.3.8 in Visual Studio

515 views
Skip to first unread message

Ben Stucki

unread,
Nov 8, 2022, 4:07:07 PM11/8/22
to fltk.general
When I try to build fltk.sln project in Visual Studio on Microsoft system I get the following errors:
1)  C2059    syntax error: 'constant'    resizebox    C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\winnt.h    6651    
2)   C2238    unexpected token(s) preceding ';'    resizebox    C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\winnt.h    6651    

both of which occur in line 6651 of the file winnt.h. Is there something that I am missing or doing wrong? 

Thanks in advance to anyone that can help.

Ian MacArthur

unread,
Nov 9, 2022, 7:46:48 AM11/9/22
to fltk.general
Be useful to know what fltk version you are trying to build, and which version of VS, etc.

I've never seen that error,  is that all it says or is there more context to explain what happened, or...?
And you are sure the error is flagged against winnt.h and not some other file that uses winnt.h? The point being, of course, that winnt.h is not one of "our" files, it is a system file - and one we do not even include directly either, only ever via windows.h IIRC.
So... that just looks like a very odd error to be getting.

Can you build other things OK with that VS? Maybe something has trampled on your system headers or something? 
I don't think I've seen something quite like that before though....

OK - just ran a quick smoke test with VS2019 and the current tip of the fltk repo, and all seems fine for me.
Dunno...

 

Albrecht Schlosser

unread,
Nov 9, 2022, 9:20:43 AM11/9/22
to fltkg...@googlegroups.com
As Ian said already, this error message is not one of the usual error messages.

We need more info to be able to help you. Please tell us more about your build setup, i.e.

- FLTK version: you wrote "1.3.8", that's OK
- where did you download FLTK 1.3.8 from? (just in case you're not using an official download)
- which Visual Studio version?
- did you use CMake to create the FLTK IDE files, or ...
- which one of the bundled IDE projects are you trying to build?

Note that there are two 'fltk.sln' files:
  ide/VisualC2008/fltk.sln
  ide/VisualC2010/fltk.sln

The best would be to let us know about all your build steps that lead to this error message.

Another option would be to try one of the latest snapshots of FLTK 1.4.0 but then you need to use CMake to build your VS project files.

Ben Stucki

unread,
Nov 9, 2022, 12:44:43 PM11/9/22
to fltk.general
To be honest, I am new to programming so this is the first thing that I have tried to build.

- I am using Visual Studio 2022 (specifically version 17.2.6)
- I downloaded FLTK 1.3.8 from here: https://www.fltk.org/software.php
- I am trying to build the ide VisualC2010 project. ie: 

        ide/VisualC2010/fltk.sln

My procedure for building follows the steps from the "README.MSWindows" file (specifically the "HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER" section). I unzip the downloaded fltk file using 7-Zip and store it in the equivalent to my dev folder. Then I open the file  .../fltk-1.3.xxxx/ide/VisualC2010/fltk.sln in Visual Studio. I make sure "demo" project is set as Startup Project and proceed to Build Solution in the Build tab. I have included a screenshot of my screen when the build fails. The README file states that the only prerequisite is VisualC which I presume is the same as the developement with C++, which I have. I hope this gives a clear picture of what I have done to get this error.

Thanks.
Screenshot_20221109_100656.png

Ian MacArthur

unread,
Nov 10, 2022, 3:32:24 AM11/10/22
to fltk.general
On Wednesday, 9 November 2022 at 17:44:43 UTC Ben Stucki wrote:
To be honest, I am new to programming so this is the first thing that I have tried to build.

- I am using Visual Studio 2022 (specifically version 17.2.6)
- I downloaded FLTK 1.3.8 from here: https://www.fltk.org/software.php
- I am trying to build the ide VisualC2010 project. ie: 

        ide/VisualC2010/fltk.sln

Sounds like it should work... I do not have VS 2022, but the last few VS iterations I have used have done a fair job of reading the old .sln file and so forth...

 

My procedure for building follows the steps from the "README.MSWindows" file (specifically the "HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER" section). I unzip the downloaded fltk file using 7-Zip and store it in the equivalent to my dev folder. Then I open the file  .../fltk-1.3.xxxx/ide/VisualC2010/fltk.sln in Visual Studio. I make sure "demo" project is set as Startup Project and proceed to Build Solution in the Build tab.

TBH, what I *actually* do when building the fltk "solution" in VS is right-click on the "Solution" at the top of the browser then select "build project" from the context menu.
To date, that has always Just Worked.

I have no idea at all why your setup is not also Just Working; it is most strange.

 

Albrecht Schlosser

unread,
Nov 10, 2022, 11:36:38 AM11/10/22
to fltkg...@googlegroups.com
On 11/10/22 09:32 Ian MacArthur wrote:
On Wednesday, 9 November 2022 at 17:44:43 UTC Ben Stucki wrote:
To be honest, I am new to programming so this is the first thing that I have tried to build.

- I am using Visual Studio 2022 (specifically version 17.2.6)
- I downloaded FLTK 1.3.8 from here: https://www.fltk.org/software.php
- I am trying to build the ide VisualC2010 project. ie: 

        ide/VisualC2010/fltk.sln

Sounds like it should work... I do not have VS 2022, but the last few VS iterations I have used have done a fair job of reading the old .sln file and so forth...

I can only agree with Ian and add that I also don't have VS 2022 installed (I'm using VS 2019 on Windows 10 for testing FLTK). I don't remember when I tried building FLTK 1.3 the last time (it's probably long ago).

That said, I'm not a fan of telling other to "reinstall" their software, but: are you sure you VS 2022 installation is correct and up-to-date? You can supposedly check if there's a new patch available inside the VS application.

As I said, I don't recommend reinstalling software (I hate to do this, it shouldn't be necessary), but maybe reinstalling VS 2022 or trying VS 2019 could help.

However, before you do this, can you try to build a standard "hello world" program with your existing VS 2022?


Ian MacArthur

unread,
Nov 10, 2022, 11:41:22 AM11/10/22
to fltk.general
On Thursday, 10 November 2022 at 16:36:38 UTC Albrecht wrote:

That said, I'm not a fan of telling other to "reinstall" their software, but: are you sure you VS 2022 installation is correct and up-to-date? You can supposedly check if there's a new patch available inside the VS application.

As I said, I don't recommend reinstalling software (I hate to do this, it shouldn't be necessary), but maybe reinstalling VS 2022 or trying VS 2019 could help.

However, before you do this, can you try to build a standard "hello world" program with your existing VS 2022?

The VS2019 Launcher GUI thing, that handles updates and such, has a "repair installation" option - I assume the VS2022 also has such a thing?
Might be less scary than a re-install, just checking that the current install is not broken in some way... Do not know...

 

pvrose

unread,
Nov 10, 2022, 2:22:38 PM11/10/22
to fltkg...@googlegroups.com

On 10 November 2022, at 16:36, Albrecht Schlosser <Albrech...@online.de> wrote:

>
>
>On 11/10/22 09:32 Ian MacArthur wrote:
>
>On Wednesday, 9 November 2022 at 17:44:43 UTC Ben Stucki wrote:
>
>To be honest, I am new to programming so this is the first thing that I have tried to build.
>
>- I am using Visual Studio 2022 (specifically version 17.2.6)
>
>- I downloaded FLTK 1.3.8 from here: https://www.fltk.org/software.php
>
>- I am trying to build the ide VisualC2010 project. ie: 
>
>        ide/VisualC2010/fltk.sln
>
>Sounds like it should work... I do not have VS 2022, but the last few VS iterations I have used have done a fair job of reading the old .sln file and so forth...
>
>I can only agree with Ian and add that I also don't have VS 2022 installed (I'm using VS 2019 on Windows 10 for testing FLTK). I don't remember when I tried building FLTK 1.3 the last time (it's probably long ago).

I've installed VS2022 and updated my application to it. The only change was the updating the MSVC library which went through without a problem. I didn't recompile FLTK though. I installed it on the recommendation of another library supplier (hamlib).

That said, I would rather go back to VS2019. My 8GB laptop isn't big enough now. I am actively looking for a less bloated development environment. My Linux experience is limited to Verilog rather than C++.

Phil.


>That said, I'm not a fan of telling other to "reinstall" their software, but: are you sure you VS 2022 installation is correct and up-to-date? You can supposedly check if there's a new patch available inside the VS application.
>As I said, I don't recommend reinstalling software (I hate to do this, it shouldn't be necessary), but maybe reinstalling VS 2022 or trying VS 2019 could help.
>However, before you do this, can you try to build a standard "hello world" program with your existing VS 2022?
>

>--
>You received this message because you are subscribed to the Google Groups "fltk.general" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
>To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/10868bc3-69d2-9372-2d72-624b89d7008d%40online.de.

Ben Stucki

unread,
Nov 10, 2022, 4:15:04 PM11/10/22
to fltk.general
I just updated VS to the newest version available, and the build still fails. I tried building a "Hello, World" project and I believe it worked as the output window read:

 "Build started...
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:00.092 =========="

I am pretty sure I have VS 2022 installed correctly as I have been using it for the past 3 or so months just fine. I think I will try installing VS 2019 and see if it works then.
Thanks for the recommendations though.

imm

unread,
Nov 10, 2022, 4:52:48 PM11/10/22
to General FLTK
On Thu, 10 Nov 2022, 19:22 'pvrose'  wrote:

I've installed VS2022 and updated my application to it. The only change was the updating the MSVC library which went through without a problem. I didn't recompile FLTK though. I installed it on the recommendation of another library supplier (hamlib).

That said, I would rather go back to VS2019. My 8GB laptop isn't big enough now. I am actively looking for a less bloated development environment. My Linux experience is limited to Verilog rather than C++.

Once you have VS installed, you don't need to use it, you can just call the cl compiler and so on & use the SDK etc. I think Greg uses it from the command line a fair bit, for example...

Visual Code works well using cl like that (or GCC or clang, too, for that matter) and is a lot lighter than the VS IDE.
--
Ian
From my Fairphone FP3

imm

unread,
Nov 10, 2022, 5:04:35 PM11/10/22
to General FLTK
On Thu, 10 Nov 2022, 21:15 Ben Stucki wrote:
I just updated VS to the newest version available, and the build still fails. I tried building a "Hello, World" project and I believe it worked as the output window read:

 "Build started...
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:00.092 =========="


Actually, I think that says"I didn't actually build this because it appears to be up to date already" but in any case I think we should assume that your VS is probably fine.



I am pretty sure I have VS 2022 installed correctly as I have been using it for the past 3 or so months just fine. I think I will try installing VS 2019 and see if it works then.
Thanks for the recommendations though.

This might be too much of a stretch, but there's a cmake script with 1.3.8 now I think.

Recent versions of VS have cmake "built in" so you can use that instead of the old 2010 SLN file to generate your "solution" and see if that works any better.

It worked for me to build 1.4, but...

Greg Ercolano

unread,
Nov 10, 2022, 5:15:59 PM11/10/22
to fltkg...@googlegroups.com

    Can confirm an error about winnt.h while building the resizebox test program.

    I just downloaded/installed VS 2022, built fltk 1.3.8 from the website tar file
    in "Release" mode and I get:

:
:
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(6497,11): error C2059: syntax error: 'constant'

19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(6497,16): error C2238: unexpected token(s) preceding ';'
19>Done building project "resizebox.vcxproj" -- FAILED.
:
:

========== Build: 78 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 04:48.937 ==========

    We'll look into a solution, but I wouldn't worry too much about the error
    since it's just one of the FLTK test program examples failing to build;
    the library itself has already built OK and should be usable.

    Devs, not sure what the problem is; seems to be something in the VS files
    and not FLTK. Not sure why resizebox is the only one triggering this, unless
    maybe we have a macro causing trouble.

    Looking at that section of the winnt.h file, line 6497:

   6487 //
   6488
   6489 typedef union _ARM64_NT_NEON128 {
   6490     struct {
   6491         ULONGLONG Low;
   6492         LONGLONG High;
   6493     } DUMMYSTRUCTNAME;
   6494     double D[2];
   6495     float S[4];
   6496     WORD   H[8];
   6497     BYTE  B[16];
   6498 } ARM64_NT_NEON128, *PARM64_NT_NEON128;
   6499
   6500 #if defined(_ARM64_)

    Seems to not like the 'B' in the line, if I'm counting the characters right.

Greg Ercolano

unread,
Nov 10, 2022, 5:24:10 PM11/10/22
to fltk.general
Following up: OK, yuck, in resizebox.cxx at the top of the file, before the #includes, we have these macro definitions:

    #define W1 (big ? 60 : 40)
    #define B 0
    #define W3 (5*W1+6*B)

..that 'B' definition being the problem for sure. Bad.

Yeah, so we should at least move all those macros down below all the #includes to avoid that problem, and update 1.3.8 and 1.4.x



Matthias Melcher

unread,
Nov 10, 2022, 5:26:26 PM11/10/22
to fltk.general
Yes, there is a bug in resize box that I fixed in 1.4.0 a few days ago. The first lines of the source file contain #define B 0 , and only after those unhappy defines, the header files are included. So anything in the header that has a keyword "B" will have it replaced with the number "0".

Simply move the three #define lines after the include statement, and everything is peachy.
Message has been deleted

Matthias Melcher

unread,
Nov 10, 2022, 5:28:06 PM11/10/22
to fltk.general
Whoa, Greg, two minutes apart. Awesome timing. I wish I had read this thread much sooner.

imm

unread,
Nov 10, 2022, 5:54:24 PM11/10/22
to General FLTK
On Thu, 10 Nov 2022, 22:16 Greg Ercolano wrote:

    Looking at that section of the winnt.h file, line 6497:

   6487 //
   6488
   6489 typedef union _ARM64_NT_NEON128 {
   6490     struct {
   6491         ULONGLONG Low;
   6492         LONGLONG High;
   6493     } DUMMYSTRUCTNAME;
   6494     double D[2];
   6495     float S[4];
   6496     WORD   H[8];
   6497     BYTE  B[16];
   6498 } ARM64_NT_NEON128, *PARM64_NT_NEON128;
   6499
   6500 #if defined(_ARM64_)

    Seems to not like the 'B' in the line, if I'm counting the characters right.

So that looks like a struct to hold a Neon vector for the Arm port of Windows.
Which I guess is quite a new thing - I wonder if that's why we haven't seen this before?

Albrecht Schlosser

unread,
Nov 10, 2022, 7:00:10 PM11/10/22
to fltkg...@googlegroups.com
Yes, obviously. Thanks to all who found this out and to Matthias for the fix.

I backported the fix to branch-1.3 (commit 0695e62ce811).

This fix requires a new release (1.3.9) which should be done soon.


Are there any other known urgent fixes that should make it into a new 1.3.9 release?

If not I'll prepare the release during the next days (maybe a week).

So far we have the following changes since 1.3.8 (see CHANGES):

CHANGES IN FLTK 1.3.9					RELEASED: Nov ?? 2022

FLTK 1.3.9 is a maintenance release with some fixes and enhancements.

Details:

  Albrecht Schlosser:
    Backport X11 INCR protocol fixes from 1.4.0 (issue #451)
    X11: Suppress compiler warnings when using gcc or clang
    Fix crash if a program exits before it opens a window (STR 3484).
    Fix compilation error with current Visual Studio 2022

  ManoloFLTK:
    macOS platform: fix for issue #325 Disabling IM disables Greek and Cyrillic layouts
    Fix fullscreen window level corner cases on macOS - cont'd
    Fix for issue #373 apparent with macOS platform and SDK ≤ 10.13
    Fi xfor issue #452:  Fl::get_font_name failure on OS-X.
    Fix for issue #454 : crash in Fl::get_font_name().
    Issue #469: Fl_Sys_Menu_Bar menu item shortcuts using Escape or Tab do not work on Mac

  YX:
    Fix IME problem (issue #270)

(End of new items in CHANGES).

Albrecht Schlosser

unread,
Nov 10, 2022, 7:11:30 PM11/10/22
to fltkg...@googlegroups.com
On 11/10/22 23:26 'Matthias Melcher' via fltk.general wrote:
Yes, there is a bug in resize box that I fixed in 1.4.0 a few days ago. The first lines of the source file contain #define B 0 , and only after those unhappy defines, the header files are included. So anything in the header that has a keyword "B" will have it replaced with the number "0".

Simply move the three #define lines after the include statement, and everything is peachy.

Done and committed in branch-1.3.


To the OP (Ben Stucki): we will release FLTK 1.3.9 soon which will fix this issue.


Until this is done you have several choices:

- Fix the source code yourself in test/resizebox as described above (please report if this fixes the issue for you).

- Delete or disable building the "resizebox" project in your version of the FLTK IDE project (fltk.sln).

- Install and use VS 2019 to build FLTK

Ben Stucki

unread,
Nov 11, 2022, 2:40:01 AM11/11/22
to fltk.general
I fixed the code myself (just moved the #defines below the #includes as Matthias Melcher stated) and everything seems to work now!
Thanks to everyone that figured this out! You all are awesome!

Stephen Zuniga

unread,
Nov 25, 2022, 2:18:32 AM11/25/22
to fltk.general
Hi everyone, thanks for your discussion. I came across Ben's question because I am having the same issue with Visual Studio 2022 and FLTK 1.3.8. I am attaching the same 2 errors at the same line discussed above. 

I bought a copy of  Bjarne Stroustrup's "Programming: Principles and Practice Using C++ (2nd Edition)" and I came across the VS and FLTK set up link in his website that he recommended to review. 

I read above that the issue will be resolved in 1.3.9. As I am "new",  I thought it would be better for me to wait for 1.3.9 because I didn't quite understand the suggestions and what Ben did or what line numbers were changed in winnt.h.

Can you tell me the date you plan on releasing 1.3.9 as the latest stable release?

Any suggestions would be appreciated.

Thanks,
Steve
VS errors.JPG

Greg Ercolano

unread,
Nov 25, 2022, 2:31:05 AM11/25/22
to fltkg...@googlegroups.com

On 11/24/22 23:05, Stephen Zuniga wrote:

Hi everyone, thanks for your discussion. I came across Ben's question because I am having the same issue with Visual Studio 2022 and FLTK 1.3.8. I am attaching the same 2 errors at the same line discussed above.

Hi Stephen,

    Welcome to fltk!

    You can seriously just ignore the error, as it's just one of the test demo programs that fails
    to build, and won't affect your using the library or running the other test demos.

    But if you want to fix the 1.3.8 version you have, just find these three lines
    at the top of the test/resizebox.cxx file:


#define W1 (big ? 60 : 40)
#define B 0
#define W3 (5*W1+6*B)
    ..and move them below all the #include lines, so those three lines appear here instead:
...
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Radio_Button.H>
#include <FL/fl_draw.H>
#include <FL/fl_message.H>

#define W1 (big ? 60 : 40)
#define B 0
#define W3 (5*W1+6*B)
Fl_Double_Window *window;
Fl_Box *box;
...

    That will solve that build error.


Stephen Zuniga

unread,
Nov 25, 2022, 4:57:24 AM11/25/22
to fltkg...@googlegroups.com

Thank you, Greg!!

I really appreciate your quick reply and helpful response.

I will give it a try and I am sure it will work fine. And it is very reassuring to read that it won't affect the build or the other test demos.

Thanks again for your help!

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/4c412c3b-303e-418d-0390-9b3914a9872e%40seriss.com.
Reply all
Reply to author
Forward
0 new messages