student c/c++ 2020-07-02 20:42 采纳率: 100%
浏览 531
已采纳

c语言中头文件宏定义编译一次后为什么在之后的编译中不可修改宏的值

#ifndef __GAME_H__
#define __GAME_H__ 

#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <time.h>

#define ROW 12//雷
#define COL 12
#define ROWS 10 //棋盘
#define COLS 10 
#define THUNDER 20 //雷数

void Arr_init(char mine[ROW][COL], char show[ROWS][COLS], int row, int col, int rows, int cols); //数组初始化
void Col_thu(char mine[ROW][COL], int row, int col, int thunder); //布置雷
void Print_che1(char mine[ROW][COL], int row, int col); //打印存雷棋盘
void Print_che2(char show[ROWS][COLS], int rows, int cols); //打印展示棋盘
char Find_thu(char mine[ROW][COL], char show[ROWS][COLS], int row, int col, int i); //找雷
void Num_mines(char mine[ROW][COL], char show[ROWS][COLS], int x, int y);//计算输入坐标周围的雷数
void open_show(char mine[ROW][COL], char show[ROWS][COLS], int rows, int x, int y);////计算输入坐标及周围的雷数(展开)
#endif // __GAME_H__

这段代码放在了一个头文件里面,为什么第一次编译后,修改define ROW的值都没有用了,比如我修改ROW 12为ROW10,程序还是依照未修改前的运行。

  • 写回答

2条回答 默认 最新

  • wlj1234 2020-07-04 16:04
    关注

    .h文件是不单独编译的,只有.c、.cpp这样的文件修改后才会自动重新编译。
    所以你要清理一下工程或者选择重新编译

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?