Emit error when board.h or config_chip.h is included before config.h

If board.h or config_chip.h is included before config.h, CONFIG_* flags
may be incorrect. For example, if config.h says:

    ...
  #define CONFIG_DEFINED_FLAG
    ...
  #include "board.h"
    ...

And board.h says:

  #ifndef __BOARD_H
  #define __BOARD_H
    ...
  #undef CONFIG_DEFINED_FLAG
    ...
  #endif

Then this code:

  #include "board.h"
  #include "config.h"

would results in CONFIG_DEFINED_FLAG being defined, instead of undefined
as stated in board.h.

Avoid this by emitting error when board.h or config_chip.h is included
before config.h.

BUG=None
TEST=make buildall
BRANCH=None

Change-Id: Ic4a8b68e8ab1ef2a4cf9e926ab9008d2b106b943
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203265
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2014-06-10 14:29:59 -07:00
committed by chrome-internal-fetch
parent 7fb019e43c
commit 2478058b7a
7 changed files with 8 additions and 6 deletions

View File

@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
#include "board.h"
#include "common.h"
#include "console.h"
#include "gpio.h"

View File

@@ -4,7 +4,6 @@
*/
/* Keyborg board-specific configuration */
#include "board.h"
#include "common.h"
#include "debug.h"
#include "master_slave.h"

View File

@@ -4,7 +4,6 @@
*/
/* GPIO UART debug printf */
#include "board.h"
#include "common.h"
#include "printf.h"
#include "registers.h"

View File

@@ -4,7 +4,7 @@
*/
/* Master/slave identification */
#include "board.h"
#include "config.h"
#include "debug.h"
#include "master_slave.h"
#include "registers.h"

View File

@@ -4,7 +4,6 @@
*/
/* Stantum board-specific SPI module */
#include "board.h"
#include "common.h"
#include "debug.h"
#include "dma.h"

View File

@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
#include "board.h"
#include "common.h"
#include "console.h"
#include "gpio.h"

View File

@@ -954,6 +954,13 @@
* Board is included after chip, so that chip defaults can be overridden on a
* per-board basis as needed.
*/
#ifdef __CROS_EC_CONFIG_CHIP_H
#error Include config.h instead of config_chip.h!
#endif
#ifdef __BOARD_H
#error Include config.h instead of board.h!
#endif
#include "config_chip.h"
#include "board.h"