git: 6e6a650c0d - main - developers-handbook/tools: update to reflect gcc exit from base

Ceri Davies <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by ceri:

URL: https://cgit.FreeBSD.org/doc/commit/?id=6e6a650c0dba453c7728e027e96a5fc2058bc7e5

commit 6e6a650c0dba453c7728e027e96a5fc2058bc7e5
Author:     Ceri Davies <[email protected]>
AuthorDate: 2021-06-29 20:00:23 +0000
Commit:     Ceri Davies <[email protected]>
CommitDate: 2021-06-29 20:00:23 +0000

    developers-handbook/tools: update to reflect gcc exit from base
    
    Remove some FAQs which clang's warnings render pointless.
    
    Reported by:    Faraz Vahedi <[email protected]>
    Differential Revision:  https://reviews.freebsd.org/D25864
---
 .../en/books/developers-handbook/tools/_index.adoc | 85 ++--------------------
 1 file changed, 6 insertions(+), 79 deletions(-)

diff --git a/documentation/content/en/books/developers-handbook/tools/_index.adoc b/documentation/content/en/books/developers-handbook/tools/_index.adoc
index ceecb30b2d..8dfcbaaa0e 100644
--- a/documentation/content/en/books/developers-handbook/tools/_index.adoc
+++ b/documentation/content/en/books/developers-handbook/tools/_index.adoc
@@ -6,7 +6,7 @@ authors:
 prev: books/developers-handbook/introduction
 next: books/developers-handbook/secure
 description: Programming Tools
-tags: ["tools", "Interpreters", "Compilers", "cc", "make", "Debugging", "lldb", "gdb", "Emacs"]
+tags: ["tools", "Interpreters", "Compilers", "cc", "make", "Debugging", "lldb", "gdb", "clang", "Emacs"]
 ---
 
 [[tools]]
@@ -173,8 +173,8 @@ Using Emacs as an IDE is discussed in <<emacs>>.
 [[tools-compiling]]
 == Compiling with `cc`
 
-This section deals with the gcc and clang compilers for C and C++, since they come with the FreeBSD base system.
-Starting with FreeBSD 10.X `clang` is installed as `cc`.
+This section deals with the clang compiler for C and C++, as it's installed with the FreeBSD base system.
+Starting with FreeBSD 10.X `clang` is installed as `cc`; the GNU compiler package:devel/gcc[gcc] is available in the Ports Collection.
 The details of producing a program with an interpreter vary considerably between interpreters, and are usually well covered in the documentation and on-line help for the interpreter.
 
 Once you have written your masterpiece, the next step is to convert it into something that will (hopefully!) run on FreeBSD.
@@ -208,7 +208,7 @@ If you have more than one file to compile, just do something like
 % cc foo.c bar.c
 ....
 
-Note that the syntax checking is just that-checking the syntax.
+Note that the syntax checking is just that - checking the syntax.
 It will not check for any logical mistakes you may have made, like putting the program into an infinite loop,
 or using a bubble sort when you meant to use a binary sort.footnote:[In case you did not know, a binary sort is an efficient way of sorting things into order and a bubble sort is not.]
 
@@ -278,12 +278,12 @@ Despite the name, it does not guarantee strictly that your code will comply to t
 Turn off _all_ ``cc``'s non-ANSI C features.
 
 Without these flags, `cc` will allow you to use some of its non-standard extensions to the standard.
-Some of these are very useful, but will not work with other compilers-in fact,
+Some of these are very useful, but will not work with other compilers - in fact,
 one of the main aims of the standard is to allow people to write code that will work with any compiler on any system.
 This is known as _portable code_.
 
 Generally, you should try to make your code as portable as possible,
-as otherwise you may have to completely rewrite the program later to get it to work somewhere else-and who knows what you may be using in a few years time?
+as otherwise you may have to completely rewrite the program later to get it to work somewhere else - and who knows what you may be using in a few years time?
 
 [source,bash]
 ....
@@ -321,79 +321,6 @@ This will both produce an executable [.filename]#foobar# from the C++ source fil
 
 === Common `cc` Queries and Problems
 
-==== I am trying to write a program which uses the sin() function and I get an error like this. What does it mean?
-
-[source,bash]
-....
-/var/tmp/cc0143941.o: Undefined symbol `_sin' referenced from text segment
-....
-
-When using mathematical functions like `sin()`, you have to tell `cc` to link in the math library, like so:
-
-[source,bash]
-....
-% cc -o foobar foobar.c -lm
-....
-
-==== All right, I wrote this simple program to practice using -lm. All it does is raise 2.1 to the power of 6.
-
-[.programlisting]
-....
-#include <stdio.h>
-
-int main() {
-	float f;
-
-	f = pow(2.1, 6);
-	printf("2.1 ^ 6 = %f\n", f);
-	return 0;
-}
-....
-
-and I compiled it as:
-
-[source,bash]
-....
-% cc temp.c -lm
-....
-
-like you said I should, but I get this when I run it:
-
-[source,bash]
-....
-% ./a.out
-2.1 ^ 6 = 1023.000000
-....
-
-This is not the right answer! What is going on?
-
-When the compiler sees you call a function, it checks if it has already seen a prototype for it.
-If it has not, it assumes the function returns an int, which is definitely not what you want here.
-
-==== So how do I fix this?
-
-The prototypes for the mathematical functions are in [.filename]#math.h#.
-If you include this file, the compiler will be able to find the prototype and it will stop doing strange things to your calculation!
-
-[.programlisting]
-....
-#include <math.h>
-#include <stdio.h>
-
-int main() {
-...
-....
-
-After recompiling it as you did before, run it:
-
-[source,bash]
-....
-% ./a.out
-2.1 ^ 6 = 85.766121
-....
-
-If you are using any of the mathematical functions, _always_ include [.filename]#math.h# and remember to link in the math library.
-
 ==== I compiled a file called foobar.c and I cannot find an executable called foobar. Where has it gone?
 
 Remember, `cc` will call the executable [.filename]#a.out# unless you tell it differently.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-doc-all
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.