C environment for learning the sufficiently hard way [closed] - c

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm new to C(coming from Java, so I'm not learning programming for the first time). I'm reading the book, "C Primer Plus". I've been searching around to understand the differences between compilers or environments to develop C programs on Windows.
I have installed MinGW and Visual Studio 2010. I have tested compiling a hello world on both environments. For MinGW, I'm considering Code::Blocks or vim. The multi compiler support on Code::Blocks sounds convenient, but I'm not at that level to comprehend how helpful this feature would be.
I'm willing to learn C the way I should be instead of being spoiled by letting the works done background hidden by IDE like Visual Studio. Once I improve my understanding, I don't mind switching to a more convenient environments.
The reason I feel uncomfortable with Visual Studio is that it doesn't support the standards as much as gcc. I have read an argument that VS is used widely in production and that this is just the way it is. Some people say just start writing C wherever which is what I don't want. I've seen some say experience the command prompt and see how the linking is done, etc.
This is from Wikipedia, but it says that Visual C++ shouldn't be used for compiling C. http://en.wikipedia.org/wiki/Visual_C%2B%2B#Issues
So here is what I need to make clear. It might be a few blocks.
My understanding is that Visual Studio is appropriate as long as I'm developing for Windows platform and also good for people who just want to start coding.
If I want to go with the more up-to-date standards and use gcc (which is used in Linux), I should go for MinGW. MinGW is the minimum gcc-like environment ported to Windows, so I can use the similar environment to Linux which benefits me for the standards better supported than VS. Also, this is supposed to help my program to be compiled more successfully on Linux and not exactly for compiling a program on Windows MinGW to run on Linux, right?
The portability we talk about is compiling a source code on each platform and not to compile a program on one particular platform to use the executed file on other platforms, correct?

Whilst Visual C++ isn't a C compiler, the Visual studio tools do allow compiing C code - the compiler under the Visual Studion is what is used to compile almost all of Microsofts C code (and there is A LOT of C code in a Microsoft Windows system, even if a fair chunk of the newer tools may be C, the basis for a lot of things is still C). You just have to ensure that you compile C as C, not as C++, since C++ has slightly different flavours of some things - some things that are allowed in C aren't in C++.
The way to do that is to call the file something.c, rather than something.cpp - it REALLY is that easy.
gcc is also a very competent compiler, absolutely no doubt about that. And using the tools in Code::Blocks etc will be a good way to learn.
I would actually say that Visual studio is definitely a smoother, slicker environment, and you can still use command-line tools like make to build things if you like - the compiler isn't part of the IDE, it's just a nicely integrated IDE. Learning a computer language should have as few obstacles as possoible. Making life hard for yourself is no help.
I personally use (x)emacs and gcc on Linux, but the first time I programmed in C, there wasn't even a proper standard for it, and computers typically had 8- or 16-bit processors - our school computer in 1985 had 2MB of ram and 3 disks of 64MB each (131000 something blocks of 512byte). That machine had 8 terminals in my school, 8 more terminals in another school, and the main school where the actual computer was had two rooms with, I think 16 terminals in each. So we sometimes shared the machine between 30 people!

You should choose whatever platform that feels the most comfortable to you, and wait with worrying about the complications of cross platform portability etc. Coming from Java you'll get your hands full with pointers and the like in the beginning, so focus on that instead of the environment.
If you have written Java in an Eclipse environment before, the CDT plugin for C/C++ might be the way to go. It does among others support the gcc tool chain.
Regards

If you're gonna compile for Windows, try CodeBlocks, Dev-CPP or Eclipse as they all use GCC i think. Essentially you want something that doesn't force you to make a new solution/include a new project / make a new file just so you could test a few functions out. You want to compile a single .c file and run it, and play in that format.
If you're gonna compile for Linux, try Geany, Eclipse or just use gcc. Might as well pick up makefiles while you're at it.
Apart from that, write C code, or look where some of those public native java calls end up. But don't look at the math package, you'll be disappointed.
EDIT: just noticed your portability. Yes, you need to recompile on every target, or use a cross-compiler.
But cross-compiling is not enough, one must write code for different platforms too, say in Windows you will use the Win API call CreateThreadA(), but in a linux-build you will probably use pthread_create(). You should get familiar with using
//some code
#ifdef __platform_windows
//windows code here
#endif
#ifdef __platform_linux
//linux code here
#endif
//crossplatform code

Related

Compatibility of source code between windows IDE and gcc?

I'm grappling with some homework which was requested as linux gcc compatible (and limited to the libraries stdio, stdlib and string). However, being unfamiliar with Linux and having to code without an IDE makes this not a pleasant experience.
Is there any reason why, sticking to the above libraries, I could make code that doesn't run the same in a windows IDE and linux' gcc? If so, is there specific factors I could avoid to keep the source code compatible between the two?

Best quick alternative compiler/IDE to Turbo C that supports audio and graphics

I am making a small 2d GAME PACK as my University project. I am using Turboc 3.0 as the compiler. I am at a stage where I need better graphics and sound. Ive spent days looking for a workaround on the net and by myself too including audio and better graphics.Can you please tell me which Ide can be learnt quickly, as time is a constraint here?
Turbo C is just an IDE + compiler for the C programming language. C does not have any audio or graphics capabilities on its own, which means that you will not find a C IDE that readily incorporates such functionality. What you need is a library with a C API that will allow you to do such things.
IIRC Turbo C did come with a rudimentary graphics library for DOS, but I do not believe that there was any support for audio. Unfortunately (or not) Turbo C is pretty much obsolete these days. Most programs written in it would have issues on modern operating systems and handling audio and graphics on DOS essentially means talking straight to the hardware - definitely not something trivial.
If you are after a modern audio/graphics library, SDL is a popular choice for 2D games and, from my experience, rather easy to work with. You will probably need to couple it with a more modern programming environment though - I doubt Turbo C will cut it. You might want to have a look at one or more of the following for a compiler and/or IDE that will be fully functional on modern systems.:
Codeblocks
Dev-C++
Warning: this IDE has not been updated for quite some time. I have used it successfully in the past, but I would not recommend investing time and resources on it at this point.
Mingw32
Eclipse CDT, downloadable here
Warning: Eclipse is mostly targeted to professional developers. It is very powerful, but it can occasionally be rather confusing to use. While it will save you a lot of time in the long run, it may not be perfectly suitable for someone that needs to get work done right here, right now.
Visual Studio Express

Strict C Win GUI programming

Good day folks, I'm in a need of a bit of guidance.
Basically, I'm a webdev who knows some C from the past, but I've only developed somewhat simple console apps for *nix.
Shortly, I want to develop a simple Win program with a GUI and not get my hands into any of the following technologies:
.NET C#
Java
C++ (especially this one)
Because I have nor the time nor the need for it currently.
1). Can I use wxWidgets without resorting to cpp (if not, what other native looking and lightweight widget toolkit would you suggest?)
2). Can I use OpenCV with strict C? (no templates, inline functions, etc)
3). Should I look for other options for a compiler besides MinGW? Is Intel one worth investigating? (AFAIK, it has a restrictive license).
4). What IDE of the following would you suggest for windows / c programming
Dev-C++
Eclipse with appropriate plugins (can't remember the exact one)
Any text editor + *.bat for compiling??
Thanks!
If you're interested in learning C-based Windows programming directly, and not using other intermediate tools:
There's a really good reference book by Charles Petzold called Programming Windows. It's definitely the way to get started. Absolutely everything is crystal clear, and you never need C++.
The Windows API, as a whole, is built for C programmers. All the fancy stuff like an actual application window is passed back as "HANDLE"s, which are more-or-less just pointers into the OS's object table. You as a programmer never have to deal with objects, just their HANDLEs.
Also, this particular book does a good job describing the Windows event-loop. If you're unfamiliar with it, it is described in generous detail.
Good luck!
For C Windows GUI programming the easiest thing is VC++ (any version since 6.0) and The Charles Petzold Programming Windows book.
The free Express version of the Microsoft compiler should work fine - I'm not sure if you'd have to download the Platform SDK or if it comes with one.
You can write Windows GUI programs in straight C. Download the Windows SDK and look at the "GENERIC" sample (I assume it's still in there). This is pretty much the minimal code required for a Win32 app, and it's in plain-ol' C.
Edit: Hmmm, it doesn't appear to be installed on this laptop. You can find it online here.
It might be worth reconsidering C#.NET. You could easily learn C# in a couple days, and be developing slick apps very quickly. Straight C-based windows libraries, particularly Win32, are BRUTAL in comparison. You'd spend a week just to write a simple app that would take minutes in C#.
The only C-based toolkit I can think of is the Windows port of GTK+. I have no experience using it in the Windows environment though. It is very mature on the Linux side though, and may be good enough if your needs are simple.
Learning the Win32 API is hard! But like others have stated, Petzold's book is the way to go if you insist on going down that path.
My opinion is that developing a Windows GUI using only C and the Win32 API would be harder to learn than picking up just enough C++ to utilize one of the C++-based frameworks. You could still do the majority of your work in plain C.
As for free IDEs, I would go with Visual Studio 2008 Express Edition.
You don't need anything.
Just use C and Win32 api , like real programmers, not kids..
See the VS Win32 wizard
Regarding wxWidgets, you can use https://sourceforge.net/projects/wxc
I never actually heavily used it, so I'm not aware of its maturity.
Mingw and Microsoft Visual C++ are my favorite compilers. Remember you can always use strict C and compile it using a C++ compiler, since valid C is almost always valid C++.
For windows, I've used Dev-C++ in the past, but nowadays Microsoft Visual C++ seems a better solution.
If you're going for text editor+bat, check out Notepad++.
EDIT: Just to clarify, using Microsoft Visual C++ does NOT mean learning C++. You can use C in it perfectly because - I repeat - valid C is often valid C++. Don't want C++? No problem. Just stay away from the C++-only features and you're still safe in a C++ compiler.
EDIT: Roger Lipscombe has noted in the comments that a pure C compiler is available in Microsoft's Visual C, using the /TC switch.

Is there a compiler or IDE for C on Windows that's regarded as an industry standard? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Taking advice from this post, I purchased a copy of 'The C Programming Language' and am happily reading my way through.
However, all the stuff I've written in the past has been interpreted, and I have no idea where to look for a good C compiler or an IDE (is there even one?). Google searches throw up a lot of results for C++ compilers, which I don't think is the same thing? Haha. I was wondering if there is a compiler or IDE for C that's regarded as an industry standard (kinda in the same way that Zend Studio is pretty much the IDE for PHP), or at least one that is generally considered to be a good quality product.
I'm surprised no-one's mentioned Pelles C. Great little C IDE for Windows; includes an LCC-based compiler. That said, NetBeans 6.5 has decent support for C and C++, and Code::Blocks is well worth a whirl.
Well, Visual Studio is the standard on Windows, and there are free versions available. However it does have a bunch of Microsoft specific extensions.
For learning though, developing console apps are pretty easy and also fairly close to the standard K&R style C.
However, way back in the day I used to use Watcom, which was also pretty good for the time. It's a lot more sparse than Visual Studio, but that can be an advantage for a beginner.
I believe it's also available for free these days at http://www.openwatcom.org/index.php/Main_Page
I'd probably recommend starting with that, if your main O/S is Windows.
Edit: new live url
Most people use Microsoft Visual Studio for development on Windows. You can get a free version here:
http://www.microsoft.com/express/download/.
Usually GCC is used on Unix, and is typically included with the OS.
C and C++ are very similar, but C++ allows classes. Most C++ compilers will compile C code.
I used DevC++ almost exclusively while I was in University for C\C++ programming. It comes bundled with the MinGW compiler. It's pretty easy to get set up and rolling. Other than this, my only other recommendation would be Visual Studio.
Almost all C++ compilers will compile C code.
I would recommend using Microsoft Visual Studio. There is a free version of it.
Most C programmers like to have their own editor and choose a compiler that fits their project. That is why you can download multiple different compilers for C and not so many built into IDE's directly.
It is easy to use editors like Editplus or even Notepad. Some of the fancier editors have syntax highlighting and can run commands in a command window for you.
IDE's usually support multiple languages as well. So when you are tired of C and want to move on to Python, Java, C++, some IDE's can help you do that. I would look into these:
Eclipse :: http://www.eclipse.org/callisto/c-dev.php
Microsoft Visual Studio :: http://www.microsoft.com/express/
GCC (GNU Compiler) and vi/emacs (or pico for uber-newbies)
Addendum: remember C is NOT a subset of C++, so a c++ compiler is not necessarily appropriate.
I recommend Quincy when you are just learning to program in C/C++. Simple to use and created for easily trying out small C/C++ programs.
You can download the Digital Mars C compiler for Windows for free.
Another good IDE is CodeBlocks, and its cross platform. Give it a try you might like it. I used it for a while an it gave me good results for what i was doing ( an image editor in C ), but it had some bugs.
For unix developing i've always liked using gcc plus an editor... it just makes it fun ( after you get use to it ).
When it comes to c/c++ compilers on the Windows platform there are quite a few to choose from.
And when it comes to and IDE, the Zeus IDE can be easily configured to work with any of them.
I used DevC++ when learning C years ago. It was a great tool, although I haven't seen it in a while so I'm not sure what state it is in now.
http://www.bloodshed.net/devcpp.html
For the record, I used TCC, the Tiny C Compiler, to quickly test small code. It can generate exe and DLLs.
You might need to download the Windows headers: it has a limited subset, you might want more.
Digital Mars also has a free C/C++ compiler of reasonable size.
GNU C is pretty much an industry standard, even if its a unixy compiler.
You can also use Visual Studio, but keep in mind it doesnt support C99 very well.
Other choices are out there, like pcc (I really like this one), llvm (also very interesting), etc, but those usually require some level of enthusiasm.
The free country website has a list of free C compilers. Many of which work on Windows.
You could use a C++ compiler, such as gcc, to compile your C code. Here's a good article with links to free C compilers/IDEs:
http://computerprogramming.suite101.com/article.cfm/freeprogrammingtools
Simply because the white book is influential, doesn't mean it's a good learning resource!
It is possibly the worst way to learn a language from that has ever existed. On top of that, last time I checked it was unreasonably expensive.
It's a complete language definition, and is good at that (which is why it truly is one of the most influential programming books). For a long time it actually was THE definition of C.
You might consider a second book on the subject.
That said, you should try quite a few different IDEs and see what you are happy with.
In fact, at first you might want to get used to vi/emacs/notepad/make and command-line compiling, this will get you a much stronger understanding of your environment (and if it's not understanding you're after, then you are barking up the wrong language-tree).
As you are investigating different IDEs, I'd give Eclipse or Netbeans with a c plugin a try. They are going to be the most complete and reliable IDEs (except, probably, for Microsoft's) and are platform independent so you won't be left in the cold when you decide to go to the Mac or Linux.

C compiler for Windows? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm fine working on Linux using gcc as my C compiler but would like a Windows solution. Any ideas? I've looked at Dev-C++ from Bloodshed but looking for more options.
You can use GCC on Windows by downloading MingW (discontinued) or its successor Mingw-w64.
You can get Visual C++ Express Edition straight from Microsoft, if you want something targeting Win32. Otherwise MinGW or lcc, as suggested elsewhere.
GCC is ubiquitous. It is trusted and well understood by thousands of folks across dozens of communities.
Visual Studio is perhaps the best IDE ever developed. It has a great compiler underneath it. But it is strictly Windows-only.
If you're just playing, get GCC --it's free. If you're concerned about multiple platfroms, it's GCC. If you're talking serious Windows development, get Visual Studio.
You could always just use gcc via cygwin.
There is another free C compiler for Windows: Pelles C.
Pelles C is a complete development kit for Windows and Windows Mobile. It contains among other things an optimizing C compiler, a macro assembler, a linker, a resource compiler, a message compiler, a make utility and install builders for both Windows and Windows Mobile.
It also contains an integrated development environment (IDE) with project management, debugger, source code editor and resource editors for dialogs, menus, string tables, accelerator tables, bitmaps, icons, cursors, animated cursors, animation videos (AVI's without sound), versions and XP manifests.
URL: http://www.smorgasbordet.com/pellesc/
I personally have been looking into using MinGW (what Bloodshed uses) with the Code Blocks IDE.
I am also considering using the Digital Mars C/C++ compiler.
Both seem to be well regarded.
GCC is not technically a linux specific compiler. Its a standards compliant c/c++ compiler, and I use it for windows programs on a daily basis. Its probably best that you use it until you become more comfortable with something else.
I recommend that you use the MinGW distribution of GCC. That will compile your programs natively for windows, using a standard library, etc.
If you're looking for an IDE, I have two recommendations. Visual Studio is the Microsoft version, and although it has its issues, it is an excellent IDE for working with the code. However, if you're looking for something a bit more lightweight, CodeBlocks is also rather good, and has the added benefit of being able to use basically any compiler you have installed (including several forms of GCC and the Microsoft Compiler that comes with Visual Studio) and being able to open project files fro other IDEs. Plus, it runs on linux too, so you could make that transition even easier on yourself.
I personally prefer GCC, but that's just me. If you really want the Microsoft Solution, VS is the way to go.
You may try Code::Blocks, which is better IDE and comes with MinGW GCC! I have used it and its just too good a freeware IDE for C/C++.
MinGW would be a direct translation off gcc for windows, or you might want to check out LCC, vanilla c (more or less) with an IDE. Pelles C seems to be based off lcc and has a somewhat nicer IDE, though I haven't used it personally. Of course there is always the Express Edition of MSVC which is free, but that's your call.
Most universities give you access to Microsoft Dreamspark.
If you're using GCC/Linux in class, just install Ubuntu. Windows is a terrible platform for C development.
Be careful to use a C compiler, not C++ if you're actually doing C. While most programs in C will work using a C++ compiler there are enough differences that there can be problems. I would agree with the people who suggest using gcc via cygwin.
EDIT:
http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B shows some of the major differences
http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite
GCC works fine. Note that MSVC is not necessarily a valid solution because it does not support C99.
I'm late to this party, but for any future C folks on Windows, Visual Studio targets C90 instead of C99, which is what you'd get on *nix. I am currently targeting C99 on Windows by using Sublime Text 2 in tandem with Cygwin.
Cygwin offers full GCC support on Windows; also, the free Microsoft Visual C++ Express Edition supports 'legacy' C projects just fine.
Visual C++ Express is a fine and free IDE for Windows which comes with a compiler.
If you are more comfortable with commandline solutions in general and gcc in particular, MinGW or Cygwin might be more up you alley. They are also both free.
There have been a few comments pointing out that C is not C++. While that's true, also true that any C++ compiler will also compile C - usually the compiler mode will be automatically selected based on the filename extension, but every compiler also has an option to force C or C++ mode regardless of the filename.
So choose the free C++ compiler that you're most comfortable with gcc, VC++ Express, Digital Mars, whatever. Use the IDE you like best emacs, vim, VC++ Express, Code::Blocks, Bloodshed - again whatever.
Any of these tools will be more than adequate for learning. Personally, since you're asking about Windows, I'd choose VC++ Express - it's a great IDE, it's free, and it'll compile C programs just fine.
It comes down to what you're using in class.
If the labs and the assignments are in linux, then you probably want a MinGW solution. If they're in windows, get Visual Studio Express.
Can't you get a free version of Visual Studio Student Addition from your school? Most Universities have programs to give free software to students.
You mean Bloodshed's Dev-C++? It's a nice visual IDE for C++ which uses MinGW's gcc for Windows as the back-the-scenes compiler. The project's been abandoned for a while (in my opinion, using Delphi to develop a C++ IDE is a very stupid thing to do to draw developers' attention), however there's nothing that stops you from using it and updating the version of MinGW's gcc it uses to the latest one - besides it's GPL-licensed.
I use either BloodShed's DEV C++, CygWin, or Visual C++ Express. All of which are free and work well. I have found that for me, DEV C++ worked the best and was the least quirky. Each compiler has it's own quirks and deifferences, you need to try out a few and find the one with which you are most comfortable. I also liked the fact that DEV C++ allowed me to change the fonts that are used in the editor. I like Proggy Programming fonts!
Must Windows C++ compilers will work.
Also, check out MinGW.

Resources