Page 1 of 1
(solved) Error flagged on this line of code:
Posted: Mon Sep 13, 2021 2:47 am
by mzimmers
Code: Select all
#include <stddef.h>
#define hexstrtobyte(a) strtol(a, NULL, 16)
expected declaration specifiers or '...' before '(' token
Can someone tell me what I'm doing wrong here? I tried this code in a different IDE, and it seemed to work.
Thanks...
Re: Error flagged on this line of code:
Posted: Mon Sep 13, 2021 6:40 am
by ESP_Sprite
What IDE is this? Does the IDE flag the code, or does the compiler?
Re: Error flagged on this line of code:
Posted: Mon Sep 13, 2021 3:12 pm
by mzimmers
Hi Sprite - sorry; I should have mentioned this is VS Code.
I get the error when I build, so I guess it's the compiler.
- error.PNG (94.31 KiB) Viewed 4626 times
That actually brings up another question I had, though: currently, errors are found/cleared on build. How do I get the errors to update without building?
Re: Error flagged on this line of code:
Posted: Tue Sep 14, 2021 6:10 am
by boarchuz
1. Check for earlier errors in the output. The quoted error may be misleading consequence of some earlier error (eg. strtol not defined).
2. #include <stdlib.h>
3. Double check every usage of the macro, the error is likely going to be there rather than within its definition.
Re: Error flagged on this line of code:
Posted: Tue Sep 14, 2021 3:25 pm
by mzimmers
Hi boarchuz - you were right; the problem wasn't with the macro itself. It was with a header file earlier in the file, which itself included another header that couldn't be found.
I'm sure I can configure VS Code to make these kinds of problems more obvious; I just haven't found out how yet.
Thanks for the help.