C complier and editor what do you use?

  • Thread starter jimmy_b_84
  • 25 comments
  • 1,318 views
69
United Kingdom
United Kingdom
jimmy_b_84
Hi all decided to take the plunge and started to learn "C" programming but just wondered what you use to to write/edit and compile/execute your code?

I extremely new to this, I like to learn new stuff taught myself XHTML and CSS via you tube along with excel stuff, I'm no expert but I've learnt enough to hold my own ish and understand how it works. So my next challenge is C and C++ (C first). I know I'm not going to create great things anytime soon as this will take me a few years but I need to start somewhere. As a 30yr with a few kids it'll take a while but I also plan to teach the kids what I've learnt when there older.

I use a Macbook (early 2011) I have access to Xcode but read this can be a little too complicated for beginners.

Advice welcomed
 
Hi all decided to take the plunge and started to learn "C" programming but just wondered what you use to to write/edit and compile/execute your code?

Advice welcomed
I use gcc and have been using it exclusively since the MSDOS days, when I used Borland C and occasionally M$oft's compilers. Gcc should be available for the Mac if it doesn't come pre-installed.

For an editor I primarily use something called joe, mostly because it used many of the same key commands as the editors packaged with the Borland and Microsoft products and my fingers didn't need to learn a whole new set of habits.

I've used both vi and emacs and really don't like either.
 
When it comes to typing out code.

I used a program called Context
It would highlight syntax commands if done correctly or incorrectly, you could also set a compiling program to start with a preset button

I used it when i did a few mods in Unreal Tournament 2004.
 
I don't program in C, but when I'm doing HTML, CSS, Javascript and, sometimes, Java, I use Sublime Text. Doesn't compile (though plugins in might exist) but it is lightweight and intuitive with clean syntax markup. Plugins exist, allowing you to tailor it to your programming needs.
 
Cheers guys really appreciate your advice.

I've installed NetBeans onto my Mac for now, looks good got to learn rouse it though.

May install some others and make a choice, once I'm up and running.

Any need to know info you would recommend I make I myself familiar with. Understanding the format and symbols used in the syntax is one of my first points of call.
 
Any need to know info you would recommend I make I myself familiar with. Understanding the format and symbols used in the syntax is one of my first points of call.
I'd say once you learn the rudiments of the language, it's essential to learn as much as you can about the C/C++ libraries you'll be using.

If you haven't already done so, it's traditional to test your compiler installation with the classic "hello.c" program:
Code:
/*      hello.c -- Hello, world */

#include <stdio.h>

int main( )
{
        printf( "Hello, world!\n" );
        return 0;
}
 
I'd say once you learn the rudiments of the language, it's essential to learn as much as you can about the C/C++ libraries you'll be using.

If you haven't already done so, it's traditional to test your compiler installation with the classic "hello.c" program:
Code:
/*      hello.c -- Hello, world */

#include <stdio.h>

int main( )
{
        printf( "Hello, world!\n" );
        return 0;
}

I shall do that, seeing as its traditional
 
If you want to teach your kids, get an Arduino. It's massively simplified compared to C but it's a great starting point to ease them in and you can do fun stuff with it, writing C software lacks that tangible aspect that younger kids may be more likely to engage with but Arduino isn't patronising either so even older kids will still engage with it. Then when it comes to learning full fat C they'll already have a good idea of how the structure works;

(C what I did there)
(I'll get my coat)
 
If you want to teach your kids, get an Arduino. It's massively simplified compared to C but it's a great starting point to ease them in and you can do fun stuff with it, writing C software lacks that tangible aspect that younger kids may be more likely to engage with but Arduino isn't patronising either so even older kids will still engage with it. Then when it comes to learning full fat C they'll already have a good idea of how the structure works;

(C what I did there)
(I'll get my coat)

haha yes very good!

Thank you for the advice, they are still very young so I've got time to get myself up to speed first, turns out this programming is quite difficult! I'll get there
 
haha yes very good!

Thank you for the advice, they are still very young so I've got time to get myself up to speed first, turns out this programming is quite difficult! I'll get there

If you find the C learning curve too steep you can always start with Python, to get a basic understanding of programming, and then move on to C from there.

Or you can stay with Python, it's pretty neat :)
 
Cheers for the advice, I thought (wrongly) that all I had to learn was C, then C++ but it turns out there is a multitude of programming languages like Java, Phyton, PHP and so on...

Just get a little confused and need to focus on one for now, I've installed netbeans on my Mac and it's very Java centric which I don't think is helping me at the moment, maybe a plain code editor without all the different code options may help. It's a work in progress as you can tell. Hats off to all programmes, it's a minefield.
 
I can recommend the small book '21st Century C' from Ben Klemens/OReilly, there are good tips how to set up your toolchain, and the techniques are modern and adapted to modern C compilers and standards. I use good old Emacs for editing -- runs everywhere but has a steep learning curve. Eclipse CDT is also a good IDE, but i recommend to try the Editor + Shell development cycle -- most IDEs try to hide it, but it's well worth knowing the basic Source File -> compile -> Object File -> link -> Executable file workings.
 
I think I'm making baby steps

the syntax #include <studio.h> means (I hope) that you call a library of commands that related to that particular language? there are many many more available that I'm learning. Still no idea if you have to store such libraries within the "project" or witch craft recalls it from Narnia ;)

Hope that's right?
 
I think I'm making baby steps

the syntax #include <studio.h> means (I hope) that you call a library of commands that related to that particular language? there are many many more available that I'm learning. Still no idea if you have to store such libraries within the "project" or witch craft recalls it from Narnia ;)

Hope that's right?

stdio.h is a "header file" with a number of declarations and definitions in it. It doesn't have any executable code; its purpose is to inform the compiler of the existence of one or more things in your program; most likely the printf() function.

For now you can think of it as a magic incantation you need to make the program compile without warnings or errors. When you get to writing your own functions other than main() you'll find that modern compilers like functions to be declared before use. And that's what's in stdio.h; a bunch of declarations most of which won't be used in your program but it's easier to just include all of them.

There are a number of other "standard" include files you'll get familiar with; you'll probably be running into stdlib.h and string.h pretty soon. There are more.


Just for grins, leave out the #include <stdio.h> line just to see what happens. The program will still compile, although the compiler will generate some warnings.
 
stdio.h is a "header file" with a number of declarations and definitions in it. It doesn't have any executable code; its purpose is to inform the compiler of the existence of one or more things in your program; most likely the printf() function.

For now you can think of it as a magic incantation you need to make the program compile without warnings or errors. When you get to writing your own functions other than main() you'll find that modern compilers like functions to be declared before use. And that's what's in stdio.h; a bunch of declarations most of which won't be used in your program but it's easier to just include all of them.

There are a number of other "standard" include files you'll get familiar with; you'll probably be running into stdlib.h and string.h pretty soon. There are more.


Just for grins, leave out the #include <stdio.h> line just to see what happens. The program will still compile, although the compiler will generate some warnings.

Cheers I think I was sort of there ish.....

I'm still very early in my learning a long way to go. Thank for the explanation very helpful
 
the syntax #include <studio.h> means (I hope) that you call a library of commands that related to that particular language? there are many many more available that I'm learning. Still no idea if you have to store such libraries within the "project" or witch craft recalls it from Narnia ;)

Open /usr/include/stdio.h with your editor, that's the actual file, the #include statement takes the contents of that file and inserts it into the source that contains the statement. That's part of the preprocessing that takes place before the actual compilation. You can use it to make reusable functions:

hello.h
Code:
#ifndef HELLO_H_INCLUDED
#define HELLO_H_INCLUDED

char const* hello();

#endif/*HELLO_H_INCLUDED*/
notice the header guard HELLO_C_INCLUDED, it's only defined once, and the whole header is skipped if included twice, so you get only one declaration even if you include the header twice. Only one function 'hello' that returns a string is declared.

hello.c
Code:
#include <hello.h>

char const* hello()
{
  return "Hello World!";
}
Here you find the definition of the function 'hello', it returns the familiar greeting, reusable for generations to come. :DNotice the include of the hello.h header.

main.c
Code:
#include <hello.h>
#include <stdio.h>
int main(int argc, char** argv)
{
  puts( hello() );
  return 0;
}
Here all is tied together, we use the 'hello' function and the standard library function 'puts' to output the returned string to stdout, and adding a newline character at the end.

then you can compile the whole stuff like that
Code:
$ c99 -I. -C hello.c -o hello.o
$ c99 -I. main.c hello.o -o hello

The first compiler invocation with the -C flag creates the hello.o object file that contains the compiled machine code. -I. is used to add the current directory to the include path, the path were files are searched that are #included. The second invocation compiles main.c and links the hello.o to form the executable hello. Hope that makes it a little clearer.:)
 
Open /usr/include/stdio.h with your editor, that's the actual file, the #include statement takes the contents of that file and inserts it into the source that contains the statement. That's part of the preprocessing that takes place before the actual compilation. You can use it to make reusable functions:

hello.h
Code:
#ifndef HELLO_H_INCLUDED
#define HELLO_H_INCLUDED

char const* hello();

#endif/*HELLO_H_INCLUDED*/
notice the header guard HELLO_C_INCLUDED, it's only defined once, and the whole header is skipped if included twice, so you get only one declaration even if you include the header twice. Only one function 'hello' that returns a string is declared.

hello.c
Code:
#include <hello.h>

char const* hello()
{
  return "Hello World!";
}
Here you find the definition of the function 'hello', it returns the familiar greeting, reusable for generations to come. :DNotice the include of the hello.h header.

main.c
Code:
#include <hello.h>
#include <stdio.h>
int main(int argc, char** argv)
{
  puts( hello() );
  return 0;
}
Here all is tied together, we use the 'hello' function and the standard library function 'puts' to output the returned string to stdout, and adding a newline character at the end.

then you can compile the whole stuff like that
Code:
$ c99 -I. -C hello.c -o hello.o
$ c99 -I. main.c hello.o -o hello

The first compiler invocation with the -C flag creates the hello.o object file that contains the compiled machine code. -I. is used to add the current directory to the include path, the path were files are searched that are #included. The second invocation compiles main.c and links the hello.o to form the executable hello. Hope that makes it a little clearer.:)

If you open stdio.h as above, do NOT modify the file! If your editor has a read-only mode, use that.

Also a little warning: stdio.h will be a bit cryptic. It will also (probably) include a number of other files.

You don't need the -I. switch, by the way. Change this line:
#include <hello.h>
to:
#include "hello.h"

But all this is really for another time, after gaining lots more experience.
 
It's still all a little confusing, ask 10 people the same question and get 10 different answers.... ;)

I think I'm going to stick with a single tutorial/guide as it'll be explained the same way every time, may help with confusion.

I thank you all for your wisdom and hopefully I'll start to actually write and understand my first very small program
 
I've finally made a decision on where I will create my "app" seeing as I run on Mac and that all the tools to create on IOS platform are there I shall try Xcode using the swift variant.

I found a lot of documentation, tutorials and even a free book via iBooks. With all this info at my finger tips I think at this stage I'd be mad not to use it. Also from a development point of view I own a Mac, iPhone 6 and access to an iPad. This should help with testing eventually!
 
Just wanted to put this.

I need help with my Eclipse Java for my Uni project. I may post more details later or via PM. Thanks.
 
gcc and vi... like a boss.


(Actually... more like software engineering peon who is directed by a boss to code stuff... so not really like a boss... even though I don't do it for work...)
 
I've finally made a decision on where I will create my "app" seeing as I run on Mac and that all the tools to create on IOS platform are there I shall try Xcode using the swift variant.

Good luck with your project, the language you use for coding doesn't matter much, it's more about being curious to learn new tricks and getting your hands dirty with coding. For example even if i code mostly C/C++ currently i got many great insights and programming approaches from a book that uses LISP/Scheme, one of the first programming languages with many parentheses. ;) Hey it's even available online, if you want to take a peak:
The Structure and Interpretation of Computer Programs.
 
Last edited:
Good luck with your project, the language you use for coding doesn't matter much, it's more about being curious to learn new tricks and getting your hands dirty with coding. For example even if i code mostly C/C++ currently i got many great insights and programming approaches from a book that uses LISP/Scheme, one of the first programming languages with many parentheses. ;) Hey it's even available online, if you want to take a peak:
The Structure and Interpretation of Computer Programs.
Thanks for that pointer to that book! I know nothing about lisp except it uses lots of parentheses,n that should help me make heads or tails out of it. Fortunately my system already has clisp installed.
 
It's been a while since I started this thread, so I thought I'd post a quick update on my progress.

As mentioned above I'm programming on the iOS platform using Xcode in swift. I've had zero programming experience prior to trying this out so it's taken me a while to understand... well everything. However I've stuck with it and have learnt the basics and last night I finally got a simple app working on my iPhone!

It's a simple version of my end goal but it's progress. I plan to complete a full app capable of providing up to date strategy calls for project cars connected to the game via the UDP data stream in project cars
 

Attachments

  • image.png
    image.png
    16 KB · Views: 12
Last edited:
image-png.525559
Final update before I get into the UDP data sent by project cars but I have a version fully working with manual inputs. Tells me a strategy overview based on data from qualifying/practice and I've also added a gesture tap to hide keyboard when done.

it's not but I'm concentrating on getting my code to work
 

Attachments

  • image.png
    image.png
    18.1 KB · Views: 27
Back