pangfengliu/stylechecker

An example to bypass the macro checker.

Closed this issue · 1 comments

#include <stdio.h>

#define SECOND3(X, Y, Z) Y
#define SECOND4(X, Y, Z, A) Y
#define SECOND5(X, Y, Z, A, B) Y

#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define SECOND(...) GET_MACRO( \
  __VA_ARGS__, SECOND5, SECOND4, SECOND3) \
  (__VA_ARGS__)

#define HIDE(X) SECOND(" \
#include <", X, ">",,)

#define FOR HIDE(f##o##r)

#define N 100

int main(){
  int sum = 0;
  FOR (int i = 0; i < N; i++)
    sum += i;
  return 0;
}

Output result:

suffix c
global variables found: 0
============================
if case while for found: 0
============================
? found: 0
============================
estimated cyclomatic complexity: 0
============================
goto found: 0
============================
asm found: 0
============================
the length of the longest line: 48

The ## is blocked. A warning messaged is added.