'GetTickCount64' was not declared in this scope

Hello,

I have been researching this without stop for about 8 hours now and am at my wits end!
I have the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
  ULONGLONG tickCount64 = GetTickCount64();
  cout << tickCount64;
}


I am compiling with this:
g++ file.cpp -o program.exe

Each time, it tells me:
1
2
3
file.cpp:13:42: error: 'GetTickCount64' was not declared in this scope
   ULONGLONG tickCount64 = GetTickCount64();
                                          ^


If I change it to GetTickCount (Without the 64), it works great. I am not running XP or anything like that, and I made sure to define the winver as Vista.
I've tried including libraries by hand, trying to add "Win32::" (And other similar combinations) in front of the function and more.

Any assistance would be most appreciated!
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724411%28v=vs.85%29.aspx does this help? sorry i dont use the winapi, but im trying to be more helpful
Thanks for the reply!
Unfortunately not. I've read that page through end to end a few times with no luck.
The code should build okay, that means that you development environment needs updating.

Edit:
DarthCaniac wrote:
#define WINVER 0x0601
...I made sure to define the winver as Vista.

Isn't Vista 0x0600?
Last edited on by Canis lupus
You need
#define _WIN32_WINNT 0x0600 before including windows.j
@Canis

Whoops, you're right! 0601 is Windows 7.


@Null

Makes no difference :(
Sorry, I skipped your first post. But my solution shoulld have worked too since GetTickcount64() is defined as follows:
1
2
3
4
5
#if (_WIN32_WINNT >= 0x0600) 
//...
WINBASEAPI ULONGLONG WINAPI GetTickCount64(void);

#endif 


maybe something has been hanged between different gcc versions
Last edited on
Your original code compiles fine using MinGW-w64 runtime from http://tdragon.net/recentgcc/ .
-------------- Build: Release in PrintEnv (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -fexceptions -m32 -D_WIN32 -O2 -c "D:\PROGRAMARE\PROIECTELE MELE\PrintEnv\main.cpp" -o obj\Release\main.o
g++.exe -L"..\..\..\CURL MinGW\lib" -o bin\Release\PrintEnv.exe obj\Release\main.o -m32 -s
Output file is bin\Release\PrintEnv.exe with size 536.00 KB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))


If your compiler does not support GetTickCount64 then use GetProcAddress() API to load the function at runtime from kernel32.dll.
You are a life saver! Thank you Modoran!

I downloaded that version of GCC and now the code compiles as nicely as can be. Thank you all very much for your help!
Topic archived. No new replies allowed.