Thread: Urgent help visualstudio build errors

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    222

    Thumbs up Urgent help visualstudio build errors

    I face errors while compiling code in vs2008 shown below. it gives unexpected errors..what could be the reason?

    Code:
    #define _WIN32_WINNT 0x0602
    #include <Windows.h>
    #include <powrprof.h>
    #include <stdio.h>
    #include <tchar.h>
    
    
    #pragma comment(lib, "PowrProf.lib")
    
    static ULONG isConnectedStandby(PVOID Context, ULONG Type, PVOID Setting);
    
    ULONG isConnectedStandby(PVOID Context, ULONG Type, PVOID Setting)
    {
    switch(Type)
    {
    case PBT_APMSUSPEND:
    printf( "PBT_APMSUSPEND");
    break;
    case PBT_APMRESUMESUSPEND:
    printf( "PBT_APMRESUMESUSPEND");
    break;
    case PBT_APMRESUMEAUTOMATIC:
    printf( "PBT_APMRESUMEAUTOMATIC");
    break;
    default:
    printf( "DEFAULT");
    break;
    }
    return 0;
    }
    
    
    static _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS testCallback = {
    isConnectedStandby,
    nullptr
    };
    
    
    int __cdecl main()
    {
    
    
    HPOWERNOTIFY RegistrationHandle;
    
    printf("Hello world\n");
    
    PowerRegisterSuspendResumeNotification(
    DEVICE_NOTIFY_CALLBACK,
    &testCallback,
    &RegistrationHandle
    ); 
    /*
    while(true) {
    Sleep(1000);
    }
    */
    return 0;
    }

    1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
    1>Deleting intermediate and output files for project 'test1', configuration 'Debug|Win32'
    1>Compiling...
    1>standby.cpp
    standby.cpp(33) : error C2146: syntax error : missing ';' before identifier 'testCallback'
    standby.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    standby.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    standby.cpp(34) : error C2440: 'initializing' : cannot convert from 'ULONG (__cdecl *)(PVOID,ULONG,PVOID)' to 'int'
    1> There is no context in which this conversion is possible
    standby.cpp(36) : error C2065: 'nullptr' : undeclared identifier
    standby.cpp(36) : error C2078: too many initializers
    standby.cpp(48) : error C2065: 'DEVICE_NOTIFY_CALLBACK' : undeclared identifier
    standby.cpp(47) : error C3861: 'PowerRegisterSuspendResumeNotification': identifier not found

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Did you bother to read the manual before using that structure?
    DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS structure (Windows)

    Minimum supported client Windows 8 [desktop apps only]
    > #define _WIN32_WINNT 0x0602
    ...
    > I face errors while compiling code in vs2008
    You need the LATEST SDK (one which supports Windows 8), and you also need Windows 8 as your platform.

    Just pasting a single #define line into the start of your code doesn't magically transform the rest of your system into Windows 8.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    222
    Where can I find latest SDK for Win8?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Somewhere on microsoft,com I guess.
    Use google for clues.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Build errors with gsl_complex
    By ZapoTex in forum C Programming
    Replies: 4
    Last Post: 05-08-2008, 11:41 AM
  2. Build Errors
    By MaGaIn in forum C++ Programming
    Replies: 5
    Last Post: 08-13-2007, 01:37 PM
  3. build errors
    By geek@02 in forum Linux Programming
    Replies: 2
    Last Post: 10-25-2005, 09:45 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 07:35 AM
  5. build errors and cin problem
    By steve043 in forum C++ Programming
    Replies: 5
    Last Post: 04-04-2004, 12:56 PM