GitHub Viewer
/*
* simplecpp - A simple and high-fidelity C/C++ preprocessor library
* Copyright (C) 2016-2023 simplecpp team
*/
#define SIMPLECPP_TOKENLIST_ALLOW_PTR 0
#include "simplecpp.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static bool isDir(const std::string& path)
{
struct stat file_stat;
if (stat(path.c_str(), &file_stat) == -1)
return false;
return (file_stat.st_mode & S_IFMT) == S_IFDIR;
}
int main(int argc, char **argv)
{
bool error = false;
const char *filename = nullptr;
enum : std::uint8_t {
File,
Fstream,
Sstream,
CharBuffer
} toklist_inf = File;
bool fail_on_error = false;
bool linenrs = false;
// Settings..
simplecpp::DUI dui;
dui.removeComments = true;
bool quiet = false;
bool error_only = false;
for (int i = 1; i < argc; i++) {
const char * const arg = argv[i];
if (*arg == '-') {
bool found = false;
const char c = arg[1];
switch (c) {
case 'D': { // define symbol
found = true;
const char * const value = arg[2] ? (argv[i] + 2) : argv[++i];
if (!value) {
std::cout