0
votes

I've just got clang running on my Mac 10.14.6, trying to run a simple HelloWorld program but I'm struggling to import/include the function library... See code below. Any help much appreciated - mega n00b alert. Isn't Mr. Robot great though.

Here's my code:

#import <stdio.h>

int main(void)    
{
printf("Hello, world!\n");
return 0;
}

and here's my error:

Michaels-MBP:tests mh$ gcc hello.c
hello.c:1:8: error: expected "FILENAME" or <FILENAME>
#import
       ^
 hello.c:4:2: warning: implicitly declaring library function 'printf' with type
      'int (const char *, ...)' [-Wimplicit-function-declaration]
        printf("Hello, WOrld!\n");
        ^
hello.c:4:2: note: include the header <stdio.h> or explicitly provide a
      declaration for 'printf'
1 warning and 1 error generated.
1
There is no #import in C, unless it's a compiler extension. Do you mean to use #include <stdio.h>?Fiddling Bits

1 Answers

2
votes

The import is unknown to C/C++, there's nothing import in it, it's notorious in Java & Python.

Use #include <stdio.h> instead.