I’m trying to run Clang-16 in Ubuntu 20 for Windows source. I have a limitation of running clang in native development machine. I have to generate AST in linux to be analysed by Clang Static Analyzer link.
hello.cpp
#include <stdio.h>
#include <windows.h> // ---> PROBLEM 1 HERE
DumpCreator* DumpCreator::m_MyObj = NULL; // ---> PROBLEM 2 HERE
int main() {
printf("Hello World");
}
Command
clang -c -x c++ hello.cpp -emit-ast -D__clang_analyzer__ -w -o hello.ast
Output
hello.cpp:2:10: fatal error: 'windows.h' file not found
#include <windows.h> // ---> PROBLEM 1 HERE
Output When Line 2 is Commented
hello.cpp:3:1: error: unknown type name 'DumpCreator'
DumpCreator* DumpCreator::m_MyObj = NULL; // ---> PROBLEM 2 HERE
^
hello.cpp:3:14: error: use of undeclared identifier 'DumpCreator'
DumpCreator* DumpCreator::m_MyObj = NULL; // ---> PROBLEM 2 HERE
^
2 errors generated.
The Problematic line is <windows.h> inclusion, as it is unavailable in linux environment. I need to tell Clang compiler to skip for missing headers and proceed. Also, when type is unknown clang throws error. Is it possible to tell clang to skip missing headers, type and emit ast.
Can anyone suggest a solution in clang to emit AST skipping errors.