Checked_C clang compiler is not able to find the stdio.h - c

Following this post, I want to give the Checked_C project a try. So I installed the latest version from here, in the C:\Program Files\CheckedC-Clang folder. Then trying this simple program:
#include <stdio_checked.h>
#include <stdchecked.h>
#pragma CHECKED_SCOPE ON
int main(int argc, nt_array_ptr<char> argv checked[] : count(argc)) {
puts("hello, world");
return 0;
}
but when trying to compile the program I get the error message:
In file included from hello-world.c:1:
C:\Program Files\CheckedC-Clang\lib\clang\12.0.1\include\stdio_checked.h:16:15: fatal error: 'stdio.h' file not found
#include_next <stdio.h>
^~~~~~~~~
1 error generated.
searching in the installation folder for dir /s stdio.h I see that it is indeed available in the below path:
C:\Program Files\CheckedC-Clang\lib\clang\12.0.1\include
then tried to compile it with
clang hello-world.c -I"C:\Program Files\CheckedC-Clang\lib\clang\12.0.1\include"
to no avail.
I would appreciate it if you could help me know what is the problem and hope I can resolve it.
P.S. Posted follow-up questions here and here.

Related

fatal error: interrupt.h: No such file or directory #include <interrupt.h>

I receive the error in the title after running the code below.
#include<stdio.h>
int main()
{
printf("hello World!\n");
return 0;
}
ADDITIONAL INFO:
header stdio.h is included in usr/include directory.
gcc compiler.
using latest Ubuntu Operating System.
C program.
file name binaryWords.c
command line: "gcc binaryWords.c -o BinaryWords."
ERROR MESSAGE FULL:
In file included from /usr/local/include/stdio.h:11:0,
from binaryWords.c:1:
/usr/local/include/thread.h:11:10: fatal error: interrupt.h: No such file or directory
#include <interrupt.h>
^~~~~~~~~~~~~
compilation terminated.
How can I fix this error?
Why is interrupt.h needed?
In Ubuntu system there is directory usr/include and usr/local/include. I had a header stdio.h for a xinu embedded system which implemented a missing interrupt.h header located in usr/local/include, hence "interrupt.h" not found error. In usr/include is the standard C library with the standard stdio.h. Once I removed the headers in usr/local/include the simple helloWorld program compiled and I was able to run the program.
possible conclusion, GCC compiler searches in usr/local/include directory before searching in usr/include directory.

Compiling with gcc in macOS Mojave

Before updating to Mojave I was compiling C programs just fine. I used an older version of gcc, 7.3, that I installed using the instructions found here.
Then I updated to Mojave and tried compiling the simple program that follows with gcc main.c:
#include <stdio.h>
int main(){
printf("Hello World\n");
return 0;}
This results in the following error:
/usr/local/lib/gcc/x86_64-apple-darwin17.5.0/7.3.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory
#include <_stdio.h>
^~~~~~~~~~
compilation terminated.
If I remove the include it will compile with implicit declaration warnings for printf, but will still compile and run properly, printing Hello World. Does anyone know the issue and how I can fix it?
I figured out how to fix it. I went to
/Library/Developer/CommandLineTools/Packages/
then opened and installed macOS_SDK_headers_for_macOS_10.14.pkg.

gcc cannot compile C files using mpi.h

I just received a message where someone could not compile a C file.
When they try to compile, it's getting the following error.
$ gcc mpi01.c
mpi01.c:1:17: fatal error: mpi.h: No such file or directory
#include <mpi.h>
^
compilation terminated.
$
I'm sure the C code is present so it must be a problem with the installation, but mpi.h is there.
/opt/mpss/3.6/sysroots/k1om-mpss-linux/usr/src/kernel/drivers/message/fusion/lsi/mpi.h
/usr/include/openmpi-x86_64/mpi.h
/usr/src/kernels/3.10.0-229.20.1.el7.x86_64/include/linux/mpi.h
Does someone know what I could do?
The system is running Centos7.
Edit 1:
To respond to the answers. It is not my code that I am trying to compile. What I did to "ensure" everything is in place for C compiling:
yum install gcc openmpi kernel-devel kernel-headers openmpi-devel
I do not know if I am allowed to post the code, but the following headers are included in the code:
#include <mpi.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
The compiler command line was the following:
vim mpi01.c
module load mpi
gcc -o mpi01 mpi01.c
Resulting in the error above.

visual studio express 2012 simple c program fatal error LNK1561: entry point must be defined

While compiling and linking the following simple test.c using: cl.exe test.c in windows 7 console:
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char* args[]){
int i;
i=0;
printf("i=%d",i);
return 0;
}
I got LINK : fatal error LNK1561: entry point must be defined. It compiles without problem, but failed in linking. Also if I change the filename to test.cpp then it works fine. Any idea?
I copied your code and compiled it with cl.exe test.c and it worked fine. I think you have a configuration problem.
First off, are you using the Visual Studio command line environment? Ensure that by typing on a command line:
vsvars32
Then try using:
cl.exe test.c kernel32.lib

gcc compiler error: "cannot find -lcs50 collect2: Id returned 1 exit status"

I have a problem in 'c' language inside compiling with gcc.
I am using "Cygwin" with (gcc-core, gcc-g++, gdb, make & other supportive packages) inside windows xp.
I installed "Cygwin" on this path "C:\Cygwin\".
My home directory: "C:\Cygwin\home\Bhanu Pratap"
I copied "cs50.h" and "cs50.c" inside my working directory which is also under "C:\Cygwin\home\Bhanu Pratap".
This is code inside my hello.c file
#include "cs50.h"
#include <stdio.h>
int
main(void){
string name = "David";
printf("O hai, %s!\n", name);
}
This is command under bash (Cygwin)
gcc -o hello hello.c -lc50
I get this error:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/id: cannot find -lcs50
collect2: Id returned 1 exit status
Please help me where i am wrong?
I'm also using the cs50 library file, and I've noticed in the code that you've used is :
#include "cs50.h"
#include <stdio.h>
and also this command :
gcc -o hello hello.c -lc50
just wondered why you used quotation marks, instead of '< >'
and the last part of the command -lc50
we normally use it this way:
#include <cs50.h>
#include <stdio.h>
and -lcs50
hope this helps \m/
To be able to use -lcs50, you'll first need to build that library (cs50) from its source code (cs50.c).
Alternatively, you could simply:
gcc -o hello hello.c cs50.c
assuming cs50.c doesn't have other dependencies.
I am using DJGPP (gcc) compiler in Windows XP for CS50 edX course.
I have tried different solutions from answers, but none of them helped me (though Mat gave me a clue).
Here is a solution:
1) copy cs50.h and cs50.c from library50-c-5.zip into a directory, where your .c source file, which you want to compile, is located.
2) type into your .c source file: #include "cs50.h"
3) compile your .c source file (at cmd.exe prompt, for example): gcc custom.c -o custom cs50.c
You may copy cmd.exe from "`C:\WINDOWS\system32" folder into your working folder (with your .c files). In this case you don't have to change directory for navigating to your working files, when you start up command prompt window.
See the link http://manual.cs50.net for relevant guidance about guidance about installing the cs50.h library. They have a precompiled version of the cs50 library that can be downloaded and installed. It is worth a try. They used gcc to compile the library, and they beginning to switch over to clang, which can also produce 64 bit compatible libraries, which is going to more useful in the future.

Resources