Skip to content

Commit

Permalink
Add errors.md (#2)
Browse files Browse the repository at this point in the history
* Add errors.md

* refer to errors.md

* Update errors.md

* Update errors.md

* Update errors.md
  • Loading branch information
mannprerak2 authored Nov 20, 2023
1 parent 15fa9ec commit ab67a57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions pkgs/ffigen/errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Errors in ffigen

This file documents various errors and their potential fixes related to ffigen.

## Errors in source header files

Under the hood ffigen uses libclang to parse header files. Any compiler warnings/errors should be logged (with SEVERE level), these should be resolved as it can potentially generate *incomplete* or *invalid* bindings that might cause silent errors at runtime.

> You can pass in args to libclang using `compiler-opts` via cmd line or yaml config or both.
Here we'll list some common usecases. You can find the full list of [supported args here](https://clang.llvm.org/docs/ClangCommandLineReference.html#id5).

### Missing headers

These are the most common source file errors. You can specify [include paths to clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#id6) like this
```yaml
compiler-opts:
- "-I/path/to/folder"
```
### Ignoring source errors
As a last resort, you can pass in `--ignore-source-errors` or set `ignore-source-errors: true` in yaml config.
2 changes: 1 addition & 1 deletion pkgs/ffigen/lib/src/header_parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ List<Binding> parseToBindings(Config c) {
_logger.warning("Ignored source errors. (ObjC)");
} else {
_logger.severe(
"Skipped generating bindings due to errors in source files. Either resolve or ignore them (Set --ignore-source-errors on cmd or ignore-source-errors:true in config.");
"Skipped generating bindings due to errors in source files. See https://github.com/dart-lang/native/blob/main/pkgs/ffigen/errors.md.");
exit(1);
}
}
Expand Down

0 comments on commit ab67a57

Please sign in to comment.