About Store Forum Documentation Contact



Post Reply 
Standard windows libraries vs. EE
Author Message
Kiekos Offline
Member

Post: #1
Standard windows libraries vs. EE
Hey there!

I needed a function that copies text to clipboard and at first I didn't realise there is ClipSet() in the engine so I made my own function following a tutorial.

This works perfectly when compiled and used as an independent console app:

Code:
#include <Windows.h>

void SetClipboard(char *text)
{
    const size_t len = strlen(text) + 1;
    HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
    memcpy(GlobalLock(hMem), text, len);
    GlobalUnlock(hMem);
    OpenClipboard(0);
    EmptyClipboard();
    SetClipboardData(CF_TEXT, hMem);
    CloseClipboard();
}

but when I tried to put it in a header file and then include it into one file in my EE project where I needed it, this happened:

Code:
Error    1    error C2143: syntax error : missing ')' before 'this'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1118    1    Tutorials
Error    2    error C2143: syntax error : missing ',' before 'this'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1118    1    Tutorials
Error    3    error C2947: expecting '>' to terminate template-parameter-list, found '>'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1118    1    Tutorials
Error    4    error C2988: unrecognizable template declaration/definition    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    5    error C2059: syntax error : '('    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    6    error C2059: syntax error : '&'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    7    error C2091: function returns function    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    8    error C2090: function returns array    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    9    error C2059: syntax error : ')'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1119    1    Tutorials
Error    10    error C2143: syntax error : missing ';' before '*'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    1254    1    Tutorials
Error    11    error C2143: syntax error : missing ';' before '*'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    2145    1    Tutorials
Error    12    error C2143: syntax error : missing ';' before 'identifier'    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    2155    1    Tutorials
Warning    13    warning C4091: 'typedef ' : ignored on left of '_M128A' when no variable is declared    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    2155    1    Tutorials
Error    14    error C1075: end of file found before the left brace '{' at 'c:\program files (x86)\windows kits\8.0\include\um\winnt.h(28)' was matched    c:\program files (x86)\windows kits\8.0\include\um\winnt.h    2155    1    Tutorials
    15    IntelliSense: expected a ';'    c:\Program Files (x86)\Windows Kits\8.0\Include\shared\windef.h    190    3    Tutorials
    16    IntelliSense: expected an identifier    c:\Program Files (x86)\Windows Kits\8.0\Include\shared\windef.h    192    9    Tutorials
    17    IntelliSense: expected an identifier    c:\Program Files (x86)\Windows Kits\8.0\Include\shared\windef.h    193    9    Tutorials
    18    IntelliSense: explicit type is missing ('int' assumed)    c:\Program Files (x86)\Windows Kits\8.0\Include\shared\windef.h    193    37    Tutorials
    19    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    3856    67    Tutorials
    20    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    3880    71    Tutorials
    21    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4037    11    Tutorials
    22    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4046    11    Tutorials
    23    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4061    11    Tutorials
    24    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4070    11    Tutorials
    25    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4088    11    Tutorials
    26    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4100    11    Tutorials
    27    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4162    108    Tutorials
    28    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4169    55    Tutorials
    29    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4335    62    Tutorials
    30    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4337    60    Tutorials
    31    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4979    91    Tutorials
    32    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4981    89    Tutorials
    33    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4986    121    Tutorials
    34    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4987    119    Tutorials
    35    IntelliSense: identifier "LPSIZE" is undefined    c:\Program Files (x86)\Windows Kits\8.0\Include\um\wingdi.h    4988    98    Tutorials
    36    IntelliSense: expected a type specifier    c:\Program Files (x86)\Windows Kits\8.0\Include\um\WinUser.h    4346    14    Tutorials
    37    IntelliSense: explicit type is missing ('int' assumed)    c:\Program Files (x86)\Windows Kits\8.0\Include\um\WinUser.h    7244    16    Tutorials
    38    IntelliSense: expected a ';'    c:\Program Files (x86)\Windows Kits\8.0\Include\um\combaseapi.h    248    1    Tutorials

I know this function is useles since ClipSet() is already there but I'm simply wondering why is it not working... This happened to me before with different functions but I simply worked my way around like this time.
04-26-2014 10:39 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #2
RE: Standard windows libraries vs. EE
#include doesn't play nice in the code editor. You have to add it in the application properties, I believe.
04-27-2014 01:02 AM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #3
RE: Standard windows libraries vs. EE
Unfortunately I'm not using the code editor but VS 2012.

Btw, I've also tried including only declaration of the function in the header file and the definition was in a .cpp file that was added to the project.

This setup works for most of my functions, but not this one... Same errors, so I guess it doesn't have anything to do with the way I include it, either way it explodes when compiled.



EDIT: And as you can see, none of the errors points at my function! Each of them points at different standard windows library saying that something's missing there or is undefined.
(This post was last modified: 04-27-2014 10:45 AM by Kiekos.)
04-27-2014 10:43 AM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #4
RE: Standard windows libraries vs. EE
did you paste "#include <windows.h>" before EE headers include? If not, try to do that.
04-28-2014 07:30 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #5
RE: Standard windows libraries vs. EE
Thanks for the hint, but unfortunately that doesn't seem to be the problem. Current setup looks like this:

Code:
//functions.h

#ifndef FUNCTIONS
#define FUNCTIONS

void SetClipboard(char *text);

#endif

and this functions.h file is included in the main.h file, which is then included in all .cpp files. The definition is in separate .cpp file that is only added to the project.

Code:
//functions.cpp

#include "stdafx.h"
#include <windows.h>

void SetClipboard(char *text)
{
    const size_t len = strlen(text) + 1;
    HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
    memcpy(GlobalLock(hMem), text, len);
    GlobalUnlock(hMem);
    OpenClipboard(0);
    EmptyClipboard();
    SetClipboardData(CF_TEXT, hMem);
    CloseClipboard();
}

and that's the whole file. But even if I put #include <windows.h> as the first header in the main file, same errors occured...
04-28-2014 10:14 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Standard windows libraries vs. EE
04-29-2014 07:24 AM
Find all posts by this user Quote this message in a reply
Post Reply