0

I use Linux Ubuntu and when I try to a compile a simple C program that prints something on the screen using

#import<stdio.h>

I get this error

#import is a deprecated GCC extension.

How am I supposed to resolve this error?

alk
  • 69,737
  • 10
  • 105
  • 255
  • Show exactly your program as some [MCVE]. Perhaps replacing `#import` by `#include` *might* be enough (or not). Without improvement your question is too broad for SO – Basile Starynkevitch Dec 29 '17 at 15:02
  • Please **edit your question** to improve it a lot (by showing some code, indented with four spaces at least in front of every line). Otherwise your question will get closed. – Basile Starynkevitch Dec 29 '17 at 15:07
  • 1
    Possible duplicate of [What is the difference between #import and #include in C?](https://stackoverflow.com/questions/39280248/what-is-the-difference-between-import-and-include-in-c) – underscore_d Dec 29 '17 at 15:25

2 Answers2

4

From GCC's CPP documentation:

CPP supports a variant of ‘#include’ called ‘#import’ which includes a file, but does so at most once.

You can safely replace #import by #include if you make sure the file referred to is using so called "header-guards".

So the 1st two lines of the file to be #included should look like

#indef SOMETHING_UNIQUE_IN_THE_CONTEXT_OF_YOUR_PROJECT
#define SOMETHING_UNIQUE_IN_THE_CONTEXT_OF_YOUR_PROJECT

then 0 to many lines

/* C stuff here */

and finally the last line should be

#endif
alk
  • 69,737
  • 10
  • 105
  • 255
1

#import<stdio.h> - wrong

#include<stdio.h>- right

SaravananKS
  • 577
  • 4
  • 18