_w64 can only be specified on int, long, and pointer types

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
dohpam1ne
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 14, 2020 11:27 pm

_w64 can only be specified on int, long, and pointer types

Post by dohpam1ne »

Hey,

First post here. Feel free to correct me on posting etiquette.

I'm attempting to compile and run the "Hello World" program described on the wxWidgets site here: https://docs.wxwidgets.org/trunk/overvi ... world.html. I'm using Visual Studio 2019 with wxWidgets 3.1.3. I compiled wxWidgets using the native x64 Visual Studio Developers Console, using this exact command: "nmake /f makefile.vc TARGET_CPU=X64". When I attempt to build my sample program (either with x64 Debug or x64 Release), I get a whole slew of errors, but the top one, which I suspect is either causing the subsequent ones or shares a common cause with the others, reads: "__w64 can only be specified on int, long, and pointer types". It references line 387 of types.h. I would greatly appreciate any help on this, I've been hardstuck for a while #-o

This was created in Visual Studio as an "empty project" type. Nothing was added to this project except the one .cpp file shown below, and the include directories for wxWidgets, which were $(WXWIDGETSFOLDER)\include and $(WXWIDGETSFOLDER)\lib\wc_x64_lib\mswud.

My sample program is exactly as follows:

Code: Select all

// wxWidgets "Hello world" Program
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};
class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
    void OnHello(wxCommandEvent& event);
    void OnExit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    wxDECLARE_EVENT_TABLE();
};
enum
{
    ID_Hello = 1
};
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Hello, MyFrame::OnHello)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
    frame->Show(true);
    return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame(NULL, wxID_ANY, title, pos, size)
{
    wxMenu* menuFile = new wxMenu;
    menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
        "Help string shown in status bar for this menu item");
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);
    wxMenu* menuHelp = new wxMenu;
    menuHelp->Append(wxID_ABOUT);
    wxMenuBar* menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "&File");
    menuBar->Append(menuHelp, "&Help");
    SetMenuBar(menuBar);
    CreateStatusBar();
    SetStatusText("Welcome to wxWidgets!");
}
void MyFrame::OnExit(wxCommandEvent& event)
{
    Close(true);
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
    wxMessageBox("This is a wxWidgets' Hello world sample",
        "About Hello World", wxOK | wxICON_INFORMATION);
}
void MyFrame::OnHello(wxCommandEvent& event)
{
    wxLogMessage("Hello world from wxWidgets!");
}
It might be helpful to note that the actual inclusion of wxWidgets headers doesn't trip it up, because I can get the program to compile with no errors if I replace the above program with something simpler:

Code: Select all

// wxWidgets "Hello world" Program
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

int main() {
    return 0;
}
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: _w64 can only be specified on int, long, and pointer types

Post by doublemax »

Why don't you start with the "minimal" sample that comes with wxWidgets that also has ready-to-go VS solution files?
Use the source, Luke!
dohpam1ne
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 14, 2020 11:27 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by dohpam1ne »

Hi doublemax,

Thanks for the sugggestion. I just tried the "calendar" sample, and it compiles and runs successfully (Debug, x86).

This makes me think that the issue must be within my project configuration, since the code itself must be alright.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: _w64 can only be specified on int, long, and pointer types

Post by ONEEYEMAN »

Hi,
It most likely is - you should start with the minial sample as it shouold just compile and run out-of-the-box.

And up to wx version 3.0.3 it actually was recommended to copy the minimal sample folder somewhere and start the development process this way.
However, now there is a properties file that can be used to create a MSVC solution.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by PB »

The second fragment "compiles" just fine, as there is nothing regarding wxWidgets that can get actually executed.

FWIW, here is a link to a simple guide to setting a wxWidgets project with MSVC:
viewtopic.php?f=19&t=46700#p196105

(Assuming you are compiling the application as 64-bit as well)

I would make sure that you include the correct setup.h first, e.g. the one from the specific build. For example, if you are NOT using MSVC-specific include (see Step 2.1 in the referenced guide) and if the libraries were built in vc_x64_lib, then that one should be used, e.g. for the Debug configuration

Code: Select all

$(WXWIN)\lib\vc_x64_lib\mswud; $(WXWIN)\include
dohpam1ne
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 14, 2020 11:27 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by dohpam1ne »

oneeyeman, I likely will end up doing that. Luckily, putting my code into the calendar sample solution works. I'm just not the type that can let go of errors easily, so I really want to understand why I'm getting an error in the first place, not just how to avoid it.

Thanks for the link, PB. I'll try to run through the setup again with the guide.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by PB »

BTW, are you sure those are actual compiler errors?

I have a hazy memory of seeing those as a bogus IntelliSense error which went away after a rebuild.
dohpam1ne
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 14, 2020 11:27 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by dohpam1ne »

I've gotten a couple of those weird IntelliSense "errors" that would go away after I'd do something like add a newline and then remove it again, but this one persists across rebuilds and tweaks and such.

I religiously followed the guide you linked with a new project (static rather than DLL, built wxwidgets with default options) and I'm getting this error:

"unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)"

I also added the wxwidgets.props file that the official guide suggested I attach to my project.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by PB »

When you use the .props file, I do not think you should (need to) do anything else.

Regarding the "main" error. Make sure thantin your project properties, in Linker / System, the SubSystem is set to "Windows (/SUBSYSTEM:WINDOWS)" (or not set at all).
dohpam1ne
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 14, 2020 11:27 pm

Re: _w64 can only be specified on int, long, and pointer types

Post by dohpam1ne »

That worked, thank you so much!

For anyone who has similar difficulties and is looking for a solution, I'll recap what I did:
  1. I built wxWidgets with the default Visual Studio Developers Console (which is x86 settings) and used default nmake settings (Also x86.).
  2. I created a new project in VS by selecting "Empty Project", and I copypasted the Hello World sample from wxWidgets into a single cpp file I added.
  3. I added wxWidgets' own properties file "wxwidgets.props" to the project, located in the top level of the wxWidgets folder.
  4. Finally, within my project's Configuration Properties, I went to Linker > System > Subsystem and set its value to "Windows (/SUBSYSTEM:WINDOWS)". It was initially set to "Console (/SUBSYSTEM:CONSOLE)".
Thanks to doublemax, ONEEYEMAN, and PB for helping me out.
Post Reply