When I’m working on a Linux machine, my C language compiler of choice is gcc. However, on a MacOS machine, the clang compiler is installed by default. I hadn’t used clang for a long time so I thought I’d do an example to refresh my memory.
I launched a bash shell by typing “terminal” in the MacOS search tool. Then I issued the command clang to make sure clang was installed on my Mac machine. I got some kind of an error message saying I had to install some sort of prerequisite so I clicked on the Install option. I can’t remember what the dependency was — I should have paid more attention. I think it might have been the Xcode (IDE) Command Line Tools set of programs.

Compiling and executing a C language program on a MacOS machine. I grabbed the screenshot using Shift + Command + 4.
After the prerequisite(s) were installed, I launched the TextEdit editor and selected the create a new file option. I wrote:
#include
int main()
{
printf("Hello there! \n");
printf("And goodbye . . . \n");
}
I saved the file as hello.c in my Documents directory. I cd’ed to the Documents directory and issued the command:
$ clang -o helloWord hello.c
The program compiled and then I executed the program by typing:
$ ./helloWorld
The clang compiler is actually a wrapper over the actual “LLVM” (originally “low level virtual machine”) compiler. Years ago, MacOS stopped using gcc because of some sort of licensing issues. Weirdly, if you issue the command “gcc” MacOS will redirect to the clang program. It is possible to install the real gcc compiler tools on a MacOS machine, but that’s another story.

Bubble wrapper dresses. Left: Elegant and attractive. Center: Creative and stylish. Right: Needs a bit of work.
.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
Visual Studio Live
Microsoft MLADS Conference
DevIntersection Conference
Machine Learning Week
Ai4 Conference
G2E Conference
iSC West Conference
You must be logged in to post a comment.