Skip to content

Instantly share code, notes, and snippets.

@emadflash
Created September 7, 2021 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emadflash/d7278cac9604f4a700daf0130b901fbd to your computer and use it in GitHub Desktop.
Save emadflash/d7278cac9604f4a700daf0130b901fbd to your computer and use it in GitHub Desktop.
weird things
void error_reporter(const char* sentence, const char* error_message, size_t offset) {
#define extra_error_offset 7
#define extra_error_prefix "^ --- "
#define extra_error_prefix_size 6
u8 n_offset = offset + extra_error_offset;
eprintln("Error: %s", sentence);
eprintln("%*s%s", n_offset, "^", error_message); // this does work
eprintln("%*s%s", n_offset, extra_error_prefix, error_message); // while this does not work
}
@emadflash
Copy link
Author

this works

void error_reporter(const char* sentence, const char* error_message, size_t offset) {
#define extra_error_offset 7 
#define extra_error_prefix "^ --- "
#define extra_error_prefix_size 5

    u8 n_offset = offset + extra_error_offset + extra_error_prefix_size;

    eprintln("Error: %s", sentence);
    eprintln("%*s%s", n_offset, extra_error_prefix, error_message);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment