json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
diag.h File Reference

Diagnostic engine for clang-style error reporting. More...

#include <stdio.h>
Include dependency graph for diag.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  diag_entry
 
struct  diag_engine
 

Macros

#define DIAG_PRINTF_FORMAT(fmt_index, first_arg)
 

Enumerations

enum  diag_severity { DIAG_ERROR , DIAG_WARNING , DIAG_NOTE }
 

Functions

struct diag_enginediag_engine_new (const char *filename, const char *source, long source_len)
 Create a new diagnostic engine.
 
void diag_engine_free (struct diag_engine *engine)
 Free a diagnostic engine and all its entries.
 
void diag_emit (struct diag_engine *engine, enum diag_severity severity, int line, int col, const char *fmt,...) DIAG_PRINTF_FORMAT(5
 Emit a diagnostic message.
 
void void diag_print_all (struct diag_engine *engine, FILE *stream)
 Print all accumulated diagnostics to a stream. Uses ANSI colors if stream is a terminal.
 
int diag_has_errors (struct diag_engine *engine)
 Check if any errors were emitted.
 
int diag_error_count (struct diag_engine *engine)
 Get the number of errors emitted.
 

Detailed Description

Diagnostic engine for clang-style error reporting.

Provides structured diagnostics with:

  • clang-style format: filename:line:col: severity: message
  • Source code snippet with caret indicator
  • Severity levels (error, warning, note)
  • ANSI color output (auto-detected via isatty)

Enumeration Type Documentation

◆ diag_severity

Diagnostic severity levels

Function Documentation

◆ diag_emit()

void diag_emit ( struct diag_engine engine,
enum diag_severity  severity,
int  line,
int  col,
const char *  fmt,
  ... 
)

Emit a diagnostic message.

Parameters
engineDiagnostic engine
severitySeverity level
line1-based line number
col1-based column number
fmtprintf-style format string

◆ diag_engine_new()

struct diag_engine * diag_engine_new ( const char *  filename,
const char *  source,
long  source_len 
)

Create a new diagnostic engine.

Parameters
filenameSource filename (not owned, must outlive engine)
sourceSource content string (not owned)
source_lenLength of source content
Returns
Pointer to new engine, or NULL on allocation failure