13
votes
Accepted
What's the difference between #include <abc.h> and #include "abc.h"
when you
#include <cs50.h>
the compiler looks for cs50.h in a standard list of system directories (e.g., /usr/include/).
on the other hand, when you
#include "cs50.h"
the compiler looks for ...
10
votes
Accepted
What does the linker do?
The #include pre-processor directive does not copy the code from libraries to your source code. It deals with header files (i.e., the ones that end with the .h extension).
In the pre-processing ...
8
votes
What does the linker do?
Well, this is a really good question that I also( at a point of time) googled up and found this image, which is enough to explain everything
So, you can see in this image that the code is first pre ...
5
votes
C language Libraries are precompiled. Then how is it linked in a different processor based computer?
They do not work. You have to compile a new version for the second processor using a compiler specific to that processor.
4
votes
Accepted
Why do I not have to link stdio.h while compiling with clang?
stdio.h is a header file from the C Standard Libraries, and their implementations are in the libc.a file, due to his common and extended use, this file is automatically linked by the compiler as if ...
3
votes
Accepted
make: Nothing to be done for `caesar'
This never has anything to do with the contents of the .c file and always to do with the location or name of the file.
It's a common error for new programmers. When you run the command make caesar, ...
3
votes
Accepted
What does -std=c99 command do?
The C programming language has many versions. -std=c99 lets the compiler know that we're using the standard version C99 (released in 1999).
See more:
http://en.m.wikipedia.org/wiki/C99
2
votes
Test program compiles with <math.h>, speller.c shows error
I needed to add -lm to the libraries and remove all headers from the Makefile.
# space-separated list of header files
HDRS = dictionary.h
# space-separated list of libraries, if any,
# each of ...
2
votes
Accepted
Trying to compile f2c.c from walkthrough week1 without success
You are in the wrong directory, change the directory to where your file is stored i.e. Desktop here
jharvard@appliance (~) : cd ~/Desktop
jharvard@appliance (~) : make f2c
jharvard@appliance (~) : ./...
2
votes
Accepted
Code in "Compilers" video shows several ^@^@^@ lines as an example of machine code. Shouldn't it be binary code?
What we're looking at here is an object file, that's object code written in "Executable and Linkable Format", being interpreted as ASCII. At least that's what I'd judge it, according to the first ...
2
votes
How does the Makefile from pset 6 work?
The makefile can be confusing at times because a lot of the steps are left out for simplicity sakes, and implied by make using default behaviour.
It might make a bit more sense if you manually ...
2
votes
Computing speed difference between n++ and n=n+1 in C
Actual compilers perform a lot of optimizations while compiling the code.
Older compilers and processors treated n++ and n=n+1 in different ways, producing a faster code for the first expression ...
2
votes
C language Libraries are precompiled. Then how is it linked in a different processor based computer?
If I get what you're asking correctly, you're asking how source code files that use compiled libraries on a specific machine compile and run properly on a different machine even if the machine code of ...
2
votes
I'm not going to use the appliance, what software should I install?
If you do not want to use the Appliance, you will need to use a compiler instead, and you will need a way to run it. Wikipedia has a list of compilers. But if you don't use the Appliance you won't ...
2
votes
Accepted
For week 4 walkthrough unused variable even though I typed the same code as David
Actually, it's not really anything to do with the code you've typed in.
Its the clang compiler complaining.
The breakout.c program would also suffer the same fate if clang was not told to suppress ...
2
votes
Accepted
Compiling Error: Make function not working
If you’re on mac then -lcrypt doesn’t exist separately. Neither does -lm for that matter. They’re both linked as part of the standard library.
Change LDLIBS to just -lcs50 and you should be good.
1
vote
Why does it keep saying error: no such file or directory?
Simple. You need to be in the same directory as the source code file to run make.
The screen shot shows that you're in the root directory. You need to switch to the directory containing the source ...
1
vote
Accepted
Why C doesn't check for memory leaks automatically?
The compiler trusts the programmer. Some code might result in a memory leak depending on how you use it. Like malloc. If you look at the code, you would not know whether it results in a memory leak. ...
1
vote
Declaring an Array - CS50 IDE
If you are coding this in Visual Studio, you cannot use GetInt() to get an integer. This is because this function is only in the CS50 library. You may have included the proper header file on the top, ...
1
vote
Accepted
Fatal error: <cs50.h> file not included
Hmmm, two consecutive questions with roughly the same issue.
After running check50 on almost every problem from pset1 to pset5, it only happened on a handful of programs. Also, it has stopped ...
1
vote
Why do we not have to link stdio?
Explicitly linking of library is only needed if you are using a non-standard library in your program such as math.h and cs50.h. Standard libraries such as stdio.h, stdlib.h, string.h, ctype.h etc. are ...
1
vote
Why do we not have to link stdio?
because, unlike the math library, the standard library is linked by default unless you tell the compiler that you don't want that to happen, which isn't usually what you need.
1
vote
How to install and compile the Stanford Portable Library on windows?
If you want to find a easier way, go for a compiler like devcpp which also compiles C code.
Since the souce for SPL is available in the comments already shared above, you can compile them and get a ...
1
vote
Accepted
I'm not going to use the appliance, what software should I install?
If you think you pc is limited, i strongly recomend you to consider installing the cs50 appliance as a second operating system, this way when you turn on your computer you can chose between windows ...
1
vote
"make" not working ("undefined reference to GetString")
I can assume that you have broken or not set CFLAGS and LDLIBS environment variables. In the same folder try to create a file called makefile and place the next lines inside it:
CC=clang
CFLAGS=-...
1
vote
Accepted
Test program compiles with <math.h>, speller.c shows error
Pay attention to these lines in your Makefile:
# space-separated list of libraries, if any,
# each of which should be prefixed with -l
LIBS =
You should add math.h so make knows it needs to link it (...
1
vote
What does -std=c99 command do?
adding further , this version of C has many cool new features which every programmer uses presently , like -
single line comments starting with //
initialising varibales where they are implemented-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
compiler × 28c × 4
cs50x × 3
week1 × 3
walkthroughs × 3
pset6 × 2
appliance × 2
error × 2
make × 2
clang × 2
week4 × 2
pset4 × 1
pset3 × 1
pset1 × 1
speller × 1
mario × 1
caesar × 1
cs50-ide × 1
fifteen × 1
memory-leak × 1
compilation-error × 1
spl × 1
cs50-library × 1
hello.c × 1
compiling × 1