capstone: compile-time version check

This version check could (and probably should) also be done in the cmake
scripts.  However, this check in CapstoneDisassembler.cpp catches another
failure mode: When a cmake script is missing a include_directories()
directive pointing to capstone.h -- resulting in a missing -I parameter to
gcc -- accidentally a system-wide 3.x capstone.h may get #included,
providing the wrong definitions and prototypes to some translation units.

Change-Id: Id30f77a47e38f4e892b92189bcce9119bf03918c
This commit is contained in:
Horst Schirmeier
2020-03-16 15:36:57 +01:00
committed by Robin Thunig
parent 1cbd5acab0
commit 63b3a5772a
2 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,8 @@
#include <capstone/capstone.h>
#if CS_MAKE_VERSION(CS_API_MAJOR, CS_API_MINOR) < CS_MAKE_VERSION(4, 0)
# error Need libcapstone >= 4.0
#endif
#include "CapstoneDisassembler.hpp"
using namespace fail;

View File

@ -14,7 +14,6 @@
#include "CapstoneToFailBochs.hpp"
#include "CapstoneToFailGem5.hpp"
#include <capstone/capstone.h>
#include <unistd.h>
#include <fcntl.h>
#include <libelf.h>