ld: symbol(s) not found for architecture arm64

Hi,all I'm writing a simple c program on my m1 MacBook with vscode ,but when I complied the project, error occurs:

Undefined symbols for architecture arm64:
  "_isDigitLetter", referenced from:
      _main in 2330004044t34main-187053.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I installed and used vscode and my program is :

//main.c
#include <stdio.h>
#include "digital.h"

int main() {
    char input;
    printf("Enter a character: ");
    scanf("%c", &input);
    printf("%c", isDigitLetter(input));
    return 0;
}
//isdigit.c
#include "digital.h"

_Bool isDigitLetter(char c) {
    return ((c >= '0') && (c<='9'));
}
//digital.h
#ifndef DIGITAL_H
#define DIGITAL_H

_Bool isDigitLetter(char c);

#endif // DIGITAL_H

I have a post, Investigating Third-Party IDE Integration Problems, that describes a good way to start debugging problems like this.

I tried your example here in my office and it worked as I expected:

% cat main.c 
#include <stdio.h>
#include "digital.h"

int main() {
    char input;
    printf("Enter a character: ");
    scanf("%c", &input);
    printf("%c", isDigitLetter(input));
    return 0;
}
% cat isdigit.c 
#include "digital.h"

_Bool isDigitLetter(char c) {
    return ((c >= '0') && (c<='9'));
}
% cat digital.h 
#ifndef DIGITAL_H
#define DIGITAL_H

_Bool isDigitLetter(char c);

#endif // DIGITAL_H

% clang main.c isdigit.c           
main.c:8:18: warning: using '%c' format specifier, but argument has boolean value [-Wformat]
    printf("%c", isDigitLetter(input));
            ~~   ^
1 warning generated.
% ./a.out 
Enter a character: 

Well, I got a warning from Clang, but the code built and ran.

I’m running on macOS 14.5 and using the command-line tools from Xcode 15.4.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

ld: symbol(s) not found for architecture arm64
 
 
Q