VC ++ 6.0 MFC - 使用<winser.h> </winser.h>中定义的宏的问题

时间:2010-08-11 06:47:14

标签: visual-c++ mfc macros compiler-errors vc6

我面临一个奇怪的问题。我有一个调用的文件,其中我使用的是一个名为“WM_USER”的宏,宏在另一个名为的文件头中定义。现在的问题是,当我在编译器中使用宏时,无法识别它。它不是我没有包括的情况,因为早些时候我没有任何问题它从没有出现。以下是编译器上显示的错误:

d:\project\project original\mirec2pc v1.0\gui\constants.h(26) : error C2065: 'WM_USER' : undeclared identifier
d:\project\project original\mirec2pc v1.0\gui\constants.h(26) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(27) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(28) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(29) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(30) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(31) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(32) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(33) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(34) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(35) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(36) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(37) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(38) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(39) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(40) : error C2057: expected constant expression

这是我的代码:

#ifndef CONSTANTS_H
#define CONSTANTS_H

#ifdef __cplusplus
extern "C"
{
#endif

#define SRCNAME_COL         0
#define REC_STATUS_COL      1
#define REC_TYPE_COL        2
#define REC_FILE_NAME_COL   3
#define REC_TIMER_COL       4


#define DLG_BK_COLOR RGB(220,228,236)
#define STATIC_BOX_BORDER_COLOR RGB(128,160,192)
#define STATIC_BOX_BORDER_DARK_COLOR RGB(83,126,200)
#define STATIC_BOX_BORDER_LIGHT_COLOR RGB(241,245,254)

#define MY_COMPUTER "My Computer"
#define FILE_NAME "\\transconf.txt"

enum
{
    WM_START_REC                = WM_USER + 100,
    WM_STOP_REC                 = WM_USER + 101,
    WM_RELOAD_SCHD              = WM_USER + 102,
    WM_CONFIG_RELOAD            = WM_USER + 103,
    WM_PROG_BAR_UPDATE          = WM_USER + 104,    //  MESSAGE TO UPDATE     THE PROGRESS BAR [10/3/2007 smkniazi]
    WM_GET_NEW_MP3_FILE         = WM_USER + 105,    //  MESSAGE TO GET NEW FILE NAME IN CASE OF FILE SPLITTING IN MP3 RECORDING
    WM_FILE_OPEN_FAILED         = WM_USER + 106,        //  MESSAGE TO MAIN GUI THAT FILE OPEN HAS FAILED IN THE MP4/MP4 FILE OPEN FUNCTION
    WM_GET_NEW_AAC_FILE         = WM_USER + 107,
    WM_GET_NEW_WAV_FILE         = WM_USER + 108,
    WM_FILENAME_CHANGED         = WM_USER + 109,
    WM_UPDATE_FILE_PATH         = WM_USER + 110,
    WM_START_STREAM             = WM_USER + 111,
    WM_UPDATE_IRECORD_LIST      = WM_USER + 150,
    WM_UPDATE_IREC_STATUS_COL   = WM_USER + 151,
    WM_CLOSE_QT_WINDOW          = WM_USER + 152,
};    


#define COMBO_COMPARISON_CHAR               '-'
#define H264_GENERIC_MP4_HEADING            "--MP4 Generic--"
#define H264_DEVICE_SPFIC_HEADING           "--Device Specific--"
#define AUDIO_ONLY_HEADING                  "--Audio Only Recording--"
#define TS_MUX_HEADING                      "--Transport     Stream--"
#define H264_QVGA_MP_AT_420Kbps_STR         "    QVGA MP@420Kbps"
#define H264_QVGA_STR                       "    QVGA (320*240)"
#define H264_VGA_STR                        "    VGA (640*480)"
#define H264_D1_STR                         "    Full D1 (720*480/576)"
#define H264_PSP_Native_STR                 "    PSP Native"
#define H264_iPhone_IPODTOUCH_Native_STR    "    iPhone/iPod Touch Native"
#define H264_PSP_QVGA_STR                   "    PSP QVGA"
#define H264_IPOD_QVGA                      "    iPod QVGA"
#define H264_IPOD_VGA                       "    iPod VGA"
#define H264_PS3_STR                        "    Apple TV/PS3"
#define H264_XBOX_360_STR                   "    XBOX 360"
#define MP3_REC_STR                         "    MP3 Audio"
#define AAC_REC_STR                         "    AAC Audio"
#define WAV_REC_STR                         "    WAV Audio"
#define FLAC_REC_STR                        "    FLAC Audio"
#define TS_MUX_QVGA_STR                     "    TSMux QVGA (320*240)"
#define TS_MUX_VGA_STR                      "    TSMux VGA  (640*480)"
#define TS_MUX_FULLD1_STR                   "    TSMux FULL D1 (720*480/576)"


#define WM_UPDATE_FILE_PROG_BAR     WM_USER+200
#define WM_EDIT_COL_UPDATED         WM_USER+201
#define WM_UPDATE_REMOVABLE_DRIVES  WM_USER+202

#ifdef __cplusplus
}
#endif

#endif

1 个答案:

答案 0 :(得分:0)

标题中没有#include,所以这是可以预料的。如果您的constants.h包含在包含WM_USER定义的标头的文件中,您的代码可以编译。但IMO总是更好地做明确的包含。

无论如何,仅#include <winuser.h>WM_USER是常量,请将其添加到标题的顶部

#ifndef WM_USER
#define WM_USER                         0x0400
#endif

干杯。