so I'm using 1 solution for multiple products and I need to make some kind of 'product id system' so i know what product people are using.
HEre is my attempt:
#ifdef _WIN64
#if defined(_DEBUG)
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 1
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 24
#endif
#else
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 25
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 48
//Then some nested #if here
#endif
#endif
#else
#if defined(_DEBUG)
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 49
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 72
#endif
#else
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 73
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 96
#endif
#endif
#endif
but it doesn't compile D: (no clue how to properly use this # system
so my question is, how can i fix the syntax error and is there a automated way i can generate product id's?
problem fixed...
changed from
#elif defined(PFW_APP_BF1)
#if defined(PFW_GAME_BF4)
#define PFW_PRODUCT_ID 51
#elif defined(PFW_GAME_BF1)
#define PFW_PRODUCT_ID 52
to
#elif defined(PFW_APP_BF1)
#elif defined(PFW_GAME_BF4)
#define PFW_PRODUCT_ID 51
#elif defined(PFW_GAME_BF1)
#define PFW_PRODUCT_ID 52
but sad that i couldn't use #if :D
Related
I'm migrating a project from VC6 to VS2019. As far as I know, _far _near are for the segmented memory model access, and _cdel _ pascal are for calling convention. All of them seem only existed in VC6 and older versions. For migration, is it safe to remove them like the #else block? Thanks!
Code:
/* 関数タイプ コンパイラ依存 */
#ifdef MSDOS
#ifdef _MSC_VER /* MS-C Ver.6.0以上 */
#define FAR _far
#define NEAR _near
#define CDECL _cdecl
#define LeafFunc _fastcall _near /* nearコール */
#define NearFunc _pascal _near /* nearコール */
#define FarLeafFunc _fastcall _far /* farコール */
#define FarFunc _pascal _far /* farコール */
#define register /* register宣言は無視 */
#else /* その他 */
#define FAR
#define NEAR
#define CDECL
#define LeafFunc
#define NearFunc
#define FarLeafFunc
#define FarFunc
#endif
NareFunc is used like the following code:
void NearFunc mmInit PT0() {
//...
}
EDIT: Thanks to 9dan. I've corrected _far and _near in the post.
Visual Studio defines _byteswap_uint64 and _byteswap_ulong in stdlib.h.
Am I right to assume, that this is not standard and won't compile on Linux or Darwin?
Is there a way to define these includes in a cross-platform way?
Google's CityHash source code uses this code:
https://github.com/google/cityhash/blob/8af9b8c2b889d80c22d6bc26ba0df1afb79a30db/src/city.cc#L50
#ifdef _MSC_VER
#include <stdlib.h>
#define bswap_32(x) _byteswap_ulong(x)
#define bswap_64(x) _byteswap_uint64(x)
#elif defined(__APPLE__)
// Mac OS X / Darwin features
#include <libkern/OSByteOrder.h>
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#elif defined(__sun) || defined(sun)
#include <sys/byteorder.h>
#define bswap_32(x) BSWAP_32(x)
#define bswap_64(x) BSWAP_64(x)
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
#elif defined(__OpenBSD__)
#include <sys/types.h>
#define bswap_32(x) swap32(x)
#define bswap_64(x) swap64(x)
#elif defined(__NetBSD__)
#include <sys/types.h>
#include <machine/bswap.h>
#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
#endif
#else
#include <byteswap.h>
#endif
I'm not aware of a cross-platform and efficient way of doing that. If you use GCC you can use the builtin byteswap like:
uint32_t __builtin_bswap32 (uint32_t x)
Those are fast but certainly not portable... unless you wrap the various versions under the appropriate ifdefs
Cheers
Francesco
Anyone got a clue how to make a vbscript popup-message/box "spawn" on top of everything and not in the background...?
This is my script: :)
Set objShell = WScript.CreateObject("WScript.Shell")
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32
intReturn = objShell.Popup("Vil du annulere shutdown?", _
20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark)
If intReturn = wshYes Then
Wscript.Echo "Shutdown annuleret."
objShell.Run "C:\ProgramData\AutoShutdown\Annuler.bat"
End If
I am very bad at vbscript, I am just using this little part for my Batch program. Any help appreciated!
It was simply by adding vbSystemModal
120, "Shutdown om 5 minutter!", wshYesNoDialog + vbSystemModal + wshQuestionMark)
The are wrappers around the API messagebox function. Just pass the numbers. Most msgbox functions just pass the numbers on so they don't need to understand them.
So use &h1000, &h2000, or &h40000
/*
* MessageBox() Flags
*/
#define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
#define MB_YESNOCANCEL 0x00000003L
#define MB_YESNO 0x00000004L
#define MB_RETRYCANCEL 0x00000005L
#if(WINVER >= 0x0500)
#define MB_CANCELTRYCONTINUE 0x00000006L
#endif /* WINVER >= 0x0500 */
#define MB_ICONHAND 0x00000010L
#define MB_ICONQUESTION 0x00000020L
#define MB_ICONEXCLAMATION 0x00000030L
#define MB_ICONASTERISK 0x00000040L
#if(WINVER >= 0x0400)
#define MB_USERICON 0x00000080L
#define MB_ICONWARNING MB_ICONEXCLAMATION
#define MB_ICONERROR MB_ICONHAND
#endif /* WINVER >= 0x0400 */
#define MB_ICONINFORMATION MB_ICONASTERISK
#define MB_ICONSTOP MB_ICONHAND
#define MB_DEFBUTTON1 0x00000000L
#define MB_DEFBUTTON2 0x00000100L
#define MB_DEFBUTTON3 0x00000200L
#if(WINVER >= 0x0400)
#define MB_DEFBUTTON4 0x00000300L
#endif /* WINVER >= 0x0400 */
#define MB_APPLMODAL 0x00000000L
#define MB_SYSTEMMODAL 0x00001000L
#define MB_TASKMODAL 0x00002000L
#if(WINVER >= 0x0400)
#define MB_HELP 0x00004000L // Help Button
#endif /* WINVER >= 0x0400 */
#define MB_NOFOCUS 0x00008000L
#define MB_SETFOREGROUND 0x00010000L
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
#if(WINVER >= 0x0400)
#define MB_TOPMOST 0x00040000L
#define MB_RIGHT 0x00080000L
#define MB_RTLREADING 0x00100000L
#endif /* WINVER >= 0x0400 */
#ifdef _WIN32_WINNT
#if (_WIN32_WINNT >= 0x0400)
#define MB_SERVICE_NOTIFICATION 0x00200000L
#else
#define MB_SERVICE_NOTIFICATION 0x00040000L
#endif
#define MB_SERVICE_NOTIFICATION_NT3X 0x00040000L
#endif
#define MB_TYPEMASK 0x0000000FL
#define MB_ICONMASK 0x000000F0L
#define MB_DEFMASK 0x00000F00L
#define MB_MODEMASK 0x00003000L
#define MB_MISCMASK 0x0000C000L
Adding + 4096 to your code will also work
20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark + 4096)
Here's google search link for objShell.Popup modal 4096
I'm trying to do something like this:
#define RELEASE_TEST
#if RELEASE
// code1
#elif RELEASE_TEST
// code2
#else
// code3
#endif
gcc claims about #elif: "error: #elif with no expression".
I do not understand this error, because I provide "RELEASE_TEST" expression to "elif".
How to make my code working?
RELEASE_TEST is defined, but with no value, so this expands to just #elif, which isn't valid.
You could either use #elif defined(RELEASE_TEST) to test if it's defined at all, or #define RELEASE_TEST 1, which would cause that line to expand to #elif 1.
In my c++ class, I want use WIN API GetFileSizeEx() function. When I compile my code, the compilator said:
"error: 'GetFileSizeEx' was not declared in this scope".
However, others functions like CreateFile() or WriteFile() work perfectly.
In my class header, I declare this :
#if defined(WINVER) && WINVER==0x0602 /* windows 8 */
#define WINVER 0x0602
#define _WIN32_WINNT 0x0602
#elif defined(WINVER) && WINVER==0x0601 /* windows 7 */
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#elif defined(WINVER) && WINVER==0x0600 /* windows vista and server 2008 */
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
#elif defined(WINVER) && WINVER==0x0502 /* server 2003 */
#define WINVER 0x0502
#define _WIN32_WINNT 0x0502
#elif defined(WINVER) && WINVER==0x0501 /* windows xp */
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
#include <winbase.h>
#include <string>
In my .cpp class:
Test::Test()
{
hFile = CreateFile(TEXT("conf/configure_tool.txt"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
canAcces = false;
}else
{
if(GetFileSizeEx(hFile,&sized) != 0)
{
canAcces = true;
}
}
}
Have you an idea to resolve my problem ?
From the documentation:
Minimum supported client Windows XP [desktop apps only]
So you need to ensure that you have defined WINVER to be 0x0501 or greater.
If that doesn't solve the problem then the likely cause is that you are using a deficient SDK. Perhaps from an old version of a non-MS compiler. Make sure that you have an up-to-date SDK.
It must be said that the conditional code in the question that attempts to define _WIN32_WINNT is a little odd. Why don't you define _WIN32_WINNT at the same time as you define WINVER?