mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Make nbErrors not extern
This commit is contained in:
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include "diagnostics.hpp"
|
#include "diagnostics.hpp"
|
||||||
|
|
||||||
extern unsigned int nbErrors;
|
|
||||||
|
|
||||||
enum WarningLevel {
|
enum WarningLevel {
|
||||||
LEVEL_DEFAULT, // Warnings that are enabled by default
|
LEVEL_DEFAULT, // Warnings that are enabled by default
|
||||||
LEVEL_ALL, // Warnings that probably indicate an error
|
LEVEL_ALL, // Warnings that probably indicate an error
|
||||||
@@ -82,4 +80,7 @@ void error(char const *fmt, ...);
|
|||||||
// once.
|
// once.
|
||||||
void error(std::function<void()> callback);
|
void error(std::function<void()> callback);
|
||||||
|
|
||||||
|
void forceError();
|
||||||
|
void requireZeroErrors();
|
||||||
|
|
||||||
#endif // RGBDS_ASM_WARNING_HPP
|
#endif // RGBDS_ASM_WARNING_HPP
|
||||||
|
|||||||
@@ -418,8 +418,8 @@ int main(int argc, char *argv[]) {
|
|||||||
fstk_Init(mainFileName, maxDepth);
|
fstk_Init(mainFileName, maxDepth);
|
||||||
|
|
||||||
// Perform parse (`yy::parser` is auto-generated from `parser.y`)
|
// Perform parse (`yy::parser` is auto-generated from `parser.y`)
|
||||||
if (yy::parser parser; parser.parse() != 0 && nbErrors == 0) {
|
if (yy::parser parser; parser.parse() != 0) {
|
||||||
nbErrors = 1;
|
forceError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fstk_FailedOnMissingInclude()) {
|
if (!fstk_FailedOnMissingInclude()) {
|
||||||
@@ -432,10 +432,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sect_CheckStack();
|
sect_CheckStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbErrors != 0) {
|
requireZeroErrors();
|
||||||
fprintf(stderr, "Assembly aborted with %u error%s!\n", nbErrors, nbErrors == 1 ? "" : "s");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If parse aborted due to missing an include, and `-MG` was given, exit normally
|
// If parse aborted due to missing an include, and `-MG` was given, exit normally
|
||||||
if (fstk_FailedOnMissingInclude()) {
|
if (fstk_FailedOnMissingInclude()) {
|
||||||
|
|||||||
@@ -125,6 +125,19 @@ void fatal(char const *fmt, ...) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void forceError() {
|
||||||
|
if (nbErrors == 0) {
|
||||||
|
nbErrors = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void requireZeroErrors() {
|
||||||
|
if (nbErrors != 0) {
|
||||||
|
fprintf(stderr, "Assembly aborted with %u error%s!\n", nbErrors, nbErrors == 1 ? "" : "s");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void warning(WarningID id, char const *fmt, ...) {
|
void warning(WarningID id, char const *fmt, ...) {
|
||||||
char const *flag = warnings.warningFlags[id].name;
|
char const *flag = warnings.warningFlags[id].name;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|||||||
Reference in New Issue
Block a user