Table Of Contents

Previous topic

bash

This Page

Visual C++

VCコンパイラ判別

#ifdef _MSC_VER

define

#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN

max, min

#define NOMINMAX

M_PI

#define _USE_MATH_DEFINES
#include <math.h>

やっつけヘッダ

#include <windows.h>

したくないときに

WinDef.h

__PRETTYPRINT__
#ifndef FALSE
#define FALSE               0
#endif

#ifndef TRUE
#define TRUE                1
#endif

// 64bit環境との互換性からunsigned longはよろしくない
//typedef unsigned long       DWORD;
typedef unsigned int       DWORD;
typedef int                 BOOL;
typedef unsigned char       BYTE;
typedef unsigned short      WORD;
typedef float               FLOAT;

afxres.hが無い

#include "afxres.h"
↓
#include <windows.h>

でOK

nmake

TARGET=sample.exe
OBJS=main.obj resource.res

all: $(TARGET)

$(TARGET): main.obj resource.res
  link /SUBSYSTEM:WINDOWS /OUT:$@ $(OBJS)

.SUFFIXES: .obj .res .rc

.cpp.obj:
  cl /c /W3 /O2 $<

.rc.res:
  rc $<

clean:
.del $(TARGET) $(OBJS)
inserted by FC2 system