(solved) Error flagged on this line of code:

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(solved) Error flagged on this line of code:

Postby mzimmers » Mon Sep 13, 2021 2:47 am

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...
Last edited by mzimmers on Tue Sep 14, 2021 3:25 pm, edited 2 times in total.

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Error flagged on this line of code:

Postby ESP_Sprite » Mon Sep 13, 2021 6:40 am

What IDE is this? Does the IDE flag the code, or does the compiler?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Error flagged on this line of code:

Postby mzimmers » Mon Sep 13, 2021 3:12 pm

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
error.PNG (94.31 KiB) Viewed 4622 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?

boarchuz
Posts: 604
Joined: Tue Aug 21, 2018 5:28 am

Re: Error flagged on this line of code:

Postby boarchuz » Tue Sep 14, 2021 6:10 am

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.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Error flagged on this line of code:

Postby mzimmers » Tue Sep 14, 2021 3:25 pm

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.

Who is online

Users browsing this forum: grantb and 33 guests