1

I've been using a language for Garry's mod (A Source-engine based physics sandbox game) called Expression 2 for a while now, Expression 2 is very heavily based on C, in fact it's almost exactly the same except for the fact it uses ,'s or line-returns to end lines, rather than ;'s. At the suggestion of a friend I gave a C tutorial a look and I found the syntax and language instantly familiar, albeit with a number of scary looking semi-colons.

In the past I've dabbled with writing emulators in Expression 2 and have had some success with a chip8 emulator and a few headaches working on a Gameboy emulator. You see, one problem with Expression 2 is the lack of proper bitwise functions and switch-case statements (Something I'm really looking forward to using in C). Likewise as the language is being interpreted ontop of LUA it's naturally very slow, great for making stuff in garry's mod but not much else.

The advantages of course of Expression 2 are easy interaction with the Game itself, it was built just to do that, working with C however would be the opposite, where interacting with the OS can be the most frustrating part.

First of all I'm wondering what are the best available C compilers for Windows 7 64bit out there? I've given Visual C++ a whirl but find its myrid of options and configurations daunting and as someone who's just starting out I'd really like a compiler that just takes my .c or .txt or whatever and outputs an application, I don't need all the bells and whistles when I'm just starting out.

Secondly as I'd like to write emulators I need a good method of drawing on the screen, as per my understanding that requires an API to interact with the OS? What's the best API for Windows 7 64 in terms of ease of use and 2d drawing? and where can I find some good documentation or tutorials on said API?

Thank you for reading, I'm really looking forward to getting stuck in with some real programming but unfortunately tutorials usually skip over things like choosing a compiler :/

Fascia
  • 732
  • 6
  • 17
  • Visual Studio makes it pretty easy to compile a simple .c file into an application. You don't need to go near the bells and whistles if you don't want to. – Oliver Charlesworth Nov 21 '10 at 20:18
  • OTOH, I'd recommend MinGW as the variant simpler to grasp. Seems like that's the matter of personal taste. – Kos Nov 21 '10 at 20:28

3 Answers3

4

MinGW will give you a minimalistic (yet complete) environment for building C code. Either of SDL or DirectX is fine for 2D graphics (and more).

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Thanks for your suggestion, giving it a download now. Reading up on SDL now too and it looks to be exactly what I was looking for. – Fascia Nov 21 '10 at 20:23
  • 1
    @Fascia- A simple quick start- after installing MinGW, open up your command prompt (since your using Windows 7, just search `cmd`) and use `cd` to navigate to the directory your code is. For example, using `cd Desktop` makes you go to your Desktop directory. Then compile using `gcc yourfile.c`. It will produce an executable, `a.exe` which you can run in the CMD simply by typing `a` – Dominic K Nov 21 '10 at 20:31
2

Most will agree that Intel C/C++ compiler still stands unbeaten, but you will be most likely OK with GCC/MinGW or MSVC (although I recommend avoiding MSVC if possible).

As for the API's. DirectX is Windows native and has best support, but you will be locked to Windows platform, but if that's what you are targeting, DirectX is your best shot I guess.

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
2

Well, a lot of questions and C makes some of them hard...

  1. As far as compilers go, you have two common options: MSVC and GCC. MSVC is the commercial (but also freely usable) compiler/toolchain which is a bit behind on C compatibility. GCC has pretty good C99 support if you need it, and available for Windows as well: http://mingw-w64.sourceforge.net (*)

  2. As for drawing on the screen, there is of course OpenGL, but that's maybe not the handiest for simple(?) 2D. Alternatives are: Direct2D, GDI(+) or any platform abstraction library like Glib which also provide simple drawing facilities.

(*) Although C compilers often come with a large set of options (you'll start to see why when you get better at coding in the language), compiling your source files to a runnable program will come down to this (GCC):

gcc -O2 *.c -lsomeLibraries -o program.exe

For the rest, read a good book, they also would get you started!

Community
  • 1
  • 1
rubenvb
  • 74,642
  • 33
  • 187
  • 332