WinMain problem


#1

trying to include a serial port communication class I got from the net (http://www.tetraedre.com/advanced/serial2.php) into my JUCE project. it had an #include <windows.h> which caused loads of grief! I got round most grief by doing




but now I’m getting

c:\SOUNDMOTION\KALI\src\Main.cpp(79) : error C2555: 'KALIApplication::moreThanOneInstanceAllowed': overriding virtual function return type differs and is not covariant from 'JUCE::JUCEApplication::moreThanOneInstanceAllowed'
        c:\SDKs\juce\src\juce_appframework\application\juce_Application.h(176) : see declaration of 'JUCE::JUCEApplication::moreThanOneInstanceAllowed'
c:\SOUNDMOTION\KALI\src\Main.cpp(84) : error C2731: 'WinMain' : function cannot be overloaded
        c:\SOUNDMOTION\KALI\src\Main.cpp(84) : see declaration of 'WinMain'

help!


#2

Try including windows.h before juce.h in your precompiled header - that’s what I do for stuff like tracktion and it works fine…


#3

cheers jules.

update…

right. just had a great joy retro-fitting PCH!

cool. the winmain grief is gone but still remains the…

c:\SOUNDMOTION\KALI\src\Main.cpp(79) : error C2555: 'KALIApplication::moreThanOneInstanceAllowed': overriding virtual function return type differs and is not covariant from 'JUCE::JUCEApplication::moreThanOneInstanceAllowed'
        c:\SDKs\juce\src\juce_appframework\application\juce_Application.h(176) : see declaration of 'JUCE::JUCEApplication::moreThanOneInstanceAllowed'

I can comment out…

    bool moreThanOneInstanceAllowed()
    {
        return true;
    }

in main.cpp, but I’d still like to know whats going on.

and while I’m here, take a look at this pile o shit!

Linking...
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
KALIMainWindow.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
KALIMainWindow.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
controller.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
controller.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
KaliSet.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
KaliSet.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
SerialPort.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in KALIMainWindow.obj; second definition ignored
DataAccessor.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
DataAccessor.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
Main.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in KALIMainWindow.obj; second definition ignored
Main.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
Main.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::max_size(void)const " (?max_size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in KaliSet.obj; second definition ignored
KALIMainWindow.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
KALIMainWindow.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
controller.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
controller.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
KaliSet.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
KaliSet.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
SerialPort.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in KALIMainWindow.obj; second definition ignored
DataAccessor.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
DataAccessor.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
Main.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in KALIMainWindow.obj; second definition ignored
Main.obj : warning LNK4006: "public: static class KaliProperties * KaliProperties::_singletonInstance" (?_singletonInstance@KaliProperties@@2PAV1@A) already defined in FretBoard.obj; second definition ignored
Main.obj : warning LNK4006: "public: static class JUCE::CriticalSection KaliProperties::_singletonLock" (?_singletonLock@KaliProperties@@2VCriticalSection@JUCE@@A) already defined in FretBoard.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::max_size(void)const " (?max_size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in KaliSet.obj; second definition ignored
msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in KaliSet.obj; second definition ignored
   Creating library .\Debug/juce_application.lib and object .\Debug/juce_application.exp
.\Debug/juce_application.exe : warning LNK4088: image being generated due to /FORCE option; image may not run

this makes no sense to me, but then I’m no expert yet. I can see NO WAY that those second definitions got in there! Image does run by the way.


#4

Isn’t Kali that old, now defunct gaming service for old games? Don’t suppose you could show us the header and namespace of it? It is almost acting like it is in the juce namespace and subclassing the main app or something…


#5

Could the problem with the moreThanOneInstance() method be because some dodgy code is redefining ‘bool’ perhaps…?


#6

bool is boolean (‘true’ or ‘false’)
BOOL is generally a WORD (‘TRUE’ or ‘FALSE’)
TRUE is 1
FALSE is 0
true is a language construct for not zero
false is a language construct effectly meaning zero

Redefining BOOL is common… to WORD though…
Redefining bool is never recommended considering it is a language construct.

If something is redefining that, then it needs to be found in that code you imported.

Hmm, also just thought, did you try having it return a BOOL and not a bool?


#7

Karbon L. Forms -> if you succed using serial port with JUCE, can you post a little example ?

Thanks


#8

Nah it’s just the codename for an in-house app I’m making. I’ll have a look at namespaces.

hmm. that sounds right actually. The serial port code had some well dodgy bool/BOOL defines on the go. some shite to do with Borland compilers. will defo check that out.

[quote=“sylfeline”]Karbon L. Forms -> if you succed using serial port with JUCE, can you post a little example ?

Thanks[/quote]

yep it’s working. get the (horrendously named) Tserial_event from http://www.tetraedre.com/advanced/serial2.php. I so far have wrapped it so…
(not yet robust code! first draft)




class SerialPort
{
public:
	SerialPort( AlertWindow* aw );
	virtual ~SerialPort ();
	void SerialCallback( Tserial_event *com_source, uint32 event );
	void OnDataArrival(int size, char *buffer);
private:
	Tserial_event* com;
	int            c;
    int            erreur;
    char           txt[32];
	char*			buffer;
    int				size;
	AlertWindow*	_aw;
};


/* ===============  CALLBACK    ===================== */
void SerialEventManager(uint32 object, uint32 event)
{
    Tserial_event *com;
	SerialPort* serial = 0;

    com = (Tserial_event *) object;
    if (com!=0)
    {
        serial = (SerialPort*)com->owner;
		if ( serial )
			serial->SerialCallback( com, event );
    }
}

//impl file



SerialPort::SerialPort( AlertWindow* aw )
:_aw( aw )
{
    com = new Tserial_event();
    if (com!=0)
    {
        com->setManager(SerialEventManager);
		com->owner = (void*)this;
        erreur = com->connect("COM1", 9600, SERIAL_PARITY_NONE, 8, false);
        if (!erreur)
            com->setRxSize(4);
        else
			AlertWindow::showMessageBox(  AlertWindow::WarningIcon
										, T("Serial Port Error")
										, T("Error: ") + String(erreur) );					
    }
}

void SerialPort::OnDataArrival(int size, char *buffer)
{
    if ((size>0) && (buffer!=0))
    {
        buffer[size] = 0;
		String s( buffer, 2 );
		if ( s == T("-<") ) _aw->keyPressed( KeyPress( KeyPress::spaceKey, ModifierKeys() ) );
		else if ( s == T("-.") ) _aw->keyPressed( KeyPress( KeyPress::escapeKey, ModifierKeys() ) );
		else if ( s == T("->") ) _aw->keyPressed( KeyPress( KeyPress::returnKey, ModifierKeys() ) );
    }
}

void SerialPort::SerialCallback( Tserial_event *com_source, uint32 event )
{
	switch(event)
        {	// only need one of these currently.
            case  SERIAL_CONNECTED		:   break;
            case  SERIAL_DISCONNECTED	:   break;
            case  SERIAL_DATA_SENT		:   break;
            case  SERIAL_RING			:   break;
            case  SERIAL_CD_ON			:   break;
            case  SERIAL_CD_OFF			:   break;
            case  SERIAL_DATA_ARRIVAL	:
                                        size   = com->getDataInSize();
                                        buffer = com->getDataInBuffer();
                                        OnDataArrival(size, buffer);
                                        com->dataHasBeenRead();
                                        break;
		}
}

SerialPort::~SerialPort()
{
	com->disconnect();
	deleteAndZero( com );
}

my hardware is a custom footpedal which currently is being used to control the three buttons on an alertwindow (via thier keypress codes) so it only sends data. hope this helps.

thanks all.


#9

well I got all that multiple defs down to

LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification KALIMainWindow.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in Main.obj; second definition ignored Serial.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in Main.obj; second definition ignored SerialPort.obj : warning LNK4006: "void __cdecl SerialEventManager(unsigned int,unsigned int)" (?SerialEventManager@@YAXII@Z) already defined in Main.obj; second definition ignored Debug/JuceKali.exe : warning LNK4088: image being generated due to /FORCE option; image may not run

mainly by removing my usage of the JUCE singleton.

SerialEventManager is a C-style function used as a callback for the Tserial_event class.

Fuck knows eh?


#10