Handmade Hero»Forums»Code
Dana Fortier
25 posts
DAY14 - can't get VS compiler to recog /DHANDMADE*
Hey,
I have tried 2 dozen different ways but I simply cannot get VS to obey the Assert macro created in the handmade.h file using #if.

I've added these flags to Proj Properties->Config Properties->Debugging->Command Arguments
/DHANDMADE_SLOW /DHANDMADE_INTERNAL /DHANDMADE_WIN_32 -FC

I've tried all permutations of the above including using '-' before the flag, using =1 after the flags and not (docs say omitting any parameter is the equivalent of using =1). VS builds and happily skips over my Assert.

However if I build from the command line it will assert! Is there an easy way to pass the command line arguments to the VS invoked cl?

Thanks!

PS: here's my handmade.h
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#if !defined(HANDMADE_H)
/* ========================================================================
$File: $
$Date: $
$Revision: $
$Creator: Dana Fortier $
$Notice: (C) Copyright 2015 by Dana Fortier, All Rights Reserved. $
======================================================================== */
/*
NOTE:
HANDMADE_INTERNAL:
0 - Build for public release
1 - Build for developer only

HANDMADE_SLOW:
0 - Not slow code allowed!
1 - Slow code welcome.
*/

#if HANDMADE_SLOW 
#define Assert(Expression) if (Expression) {*(int*)0 = 0;}
#else 
#define Assert(Expression)
#endif

#define ArrayCount(Array) (sizeof((Array))/sizeof((Array)[0]))
#define Kilobytes(Value) ((Value)*1024LL)
#define Megabytes(Value) (Kilobytes(Value)*1024LL)
#define Gigabytes(Value) (Megabytes(Value)*1024LL)

/*
	Services that the platform layer provides to the game
*/

/*
	Services that the game provides to the platform layer.
	may expand in the future ie: sound has its own thread

	NOTE: in the future renderin will become a 3 tiered abstraction
*/



struct game_memory
{
	bool32 IsInitialized;
	uint64 PermanentStorageSize;
	uint64 TransientStorageSize;
	void *PermanentStorage;
	void *TransientStorage;
};

struct game_output_sound_buffer
{
	// For sound test
	int SamplesPerSecond;
	int SampleCount;
	int16 *SamplesBuffer;


};
struct game_offscreen_vid_buffer
{
	//NOTE: Always assumes bytesperpixel is 4 (32 bit), memory order: BB GG RR XX -> in mem: 0x xx RR GG BB
	
	void *Memory;
	int Width;
	int Height;
	int Pitch;
};


struct game_button_state
{
	int HalfTransitionCount;
	bool32 EndedDown;
};

struct game_controller_input
{
	bool32 IsAnalog;

	real32 StartX;
	real32 StartY;

	real32 MinX;
	real32 MinY;

	real32 MaxX;
	real32 MaxY;

	real32 EndX;
	real32 EndY;
	

	union
	{
		game_button_state Buttons[7]; // Note: Up = Y(xbox) or Triangle(ps),
		// Down = A or X etc.
			struct
			{
				game_button_state Up;
				game_button_state Down;
				game_button_state Left;
				game_button_state Right;
				game_button_state LShoulder;
				game_button_state RShoulder;
				game_button_state Select;
				game_button_state Start;

			};
	};

};

struct game_input
{
	game_controller_input Controllers[4];
};

struct game_state
{
	int Hz;
	int VidPixelYOffset;
	int VidPixelXOffset;
};
// GameUpdateAndRender needs to take 4 things, timing, the bitmap to write, the sound to play and the input to act on
internal void GameUpdateAndRender( game_memory *GameMemory, game_input *Input, game_offscreen_vid_buffer *Buffer ,game_output_sound_buffer *SoundBuffer);

internal void GameInputEventHandler( int isInputPressed , int isInputReleased );
internal game_state  GameStartup( void );


#define HANDMADE_H
#endif
Mārtiņš Možeiko
2562 posts / 2 projects
DAY14 - can't get VS compiler to recog /DHANDMADE*
These defines are not runtime arguments for debugger. They are compile time options. You need to put them where compiler options are specified - Project Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions. Put them there separated by semicolons (or use Edit... drop down menu to put them each on individual line).
Dana Fortier
25 posts
DAY14 - can't get VS compiler to recog /DHANDMADE*
Thank you again!