How to add C compiler in MPLAB IDE v 8.0? - ide

I am trying to write some programs using MPLAB IDE in C language. For that I have installed version 8.0 MPLAB. But I could not find out the C compiler in it. So how to proceed to get the C compiler. Hope to get quick responses.
Cheers!!!

You have to install a C compiler separate. MPLAB supports several C compilers and it's easiest just to download one from Microchip. The compiler you'll need will depend on the chip family you are looking to program against whether it be 8, 16, or 32 bit. You can find more information on the various compilers available from Microchip here.

Related

Why can .c files contain blocks?

I think block is the Objective-C feature. Recently I am adding the block to some C source file and I found it just compile OK.
I get confused, for *.c file, should the compiler(Clang) consider it as the pure C file, why it can permit block?
Actually Clang introduces blocks
to C and, by extension, Objective-C, C++, and Objective-C++
As you can read here in the overview.
Of course, using blocks makes your source incompatible with C11 standard but, you know, as long as your code is for Mac OS X only...
EDIT: Blocks are also available in GCC, didn't know about it.
Blocks were added in such a manner that they are also a "C" feature in Apple's compilers.
From Apple's Blocks Programming Topics
Blocks are available in GCC and Clang as shipped with the OS X v10.6
Xcode developer tools. You can use blocks with OS X v10.6 and later,
and iOS 4.0 and later. The blocks runtime is open source and can be
found in LLVM’s compiler-rt subproject repository. Blocks have also
been presented to the C standards working group as N1370: Apple’s
Extensions to C. As Objective-C and C++ are both derived from C,
blocks are designed to work with all three languages (as well as
Objective-C++). The syntax reflects this goal.

Can Objective-C compile to C?

Can I compile an Objective-C program to C?
I'm interested if this can be done so that it can be compiled with other C compilers.
I am aware that GCC can compile Objective-C.
Sure. For example, POC compiles Objective C to plain C code, and the recommended way to use it is to then compile that C code with gcc.
Of course the generated C is an unreadable mess, consisting mostly of calls (through generated extern declarations) to objc_runtime calls, so you'll need to link that runtime to your compiled code.
There's also an LLVM backend that generates C code from any frontend. So, you can plug in the clang Objective C frontend and the C backend and build your own ObjC-to-C compiler. The result will probably be even more unreadable than what POC generates.
Of course most people don't want to compile Objective C*, they want to compile "Objective C 4.0".** POC won't do that; only clang and llvm-gcc will (and in the future, most likely only clang). And they don't just want an Objective C runtime, they want the OS X or the iOS runtime, or at least OpenStep, which again pretty much means clang, llvm-gcc, or gcc.
The big question is, why do you want to do this? You will need to have an Objective C runtime to link to, and your C code will have to be compiled in a way that's ABI-compatible with the way that runtime was compiled, so… I'm not sure what you're going to gain over just compiling from ObjC to native code with gcc or clang in the first place.
* As in the language defined in Brad Cox's 1986 book and/or in his 1991 followup.
** Note that Apple explicitly decided not to call their latest revisions to the language "Objective-C 4.0"… or anything else. The last version with a name, or a real specification, was "The Objective-C 2.0 Programming Language". But Apple has continued to add features, and the "unnamed feature set that came in with the LLVM 4.0 frontend for Objective-C 2.0" is a bit of a mouthful.
Technically, yes, but it'll be really ugly. LLVM had a C backend — i.e. it could compile to C — up to version 3.1. There have been efforts to revive it but I can't speak as to their progress. There's also a C++ backend that is better maintained but doesn't quite do the same thing.
However you'll have the obvious problem that none of the Foundation libraries will be available on your target platform. No NSString, no NSArray, etc. Once you've found a working implementation of those you'll also have found a working Objective-C compiler.

objective c on windows and gcc

Is the gnu objective c compiler for windows the same as the compiler for Mac OS X (and Ipad)?
I want to write some code on windows and run it on the mac and ipad, objective C seems to be the best way to go for the Mac/Ipad but is the gnu compiler the same? I know the libraries cocoa etc are not available but this is not an issue we'll be writing different interface code for each platform (please no comments about this is not the right way etc).
tia,
Dave
The compiler is more or less the same, but the runtime systems are different. If you don’t use the new features from Objective-C 2.0 your code should work fine with both runtime systems. If you want to use the new features you have to use a different runtime. You can find more information here on the GNUstepWiki.
But you still need a framework that provides basic objects like strings, arrays, dictionaries and so on. You could use this part from The Cocotron, a framework that tries to make all of Cocoa available on Windows, Linux and other platforms.

Is Objective C Apple specific?

Is Objective C an Apple language or can you run Objective C on other platforms like linux?
Objective-C is not an OS X/iOS specific language, eg. the GCC has its own, non Apple, ObjC runtime that also works on Linux (not sure about LLVM, but I guess they have their own runtime too).
However, the complete library (Cocoa, UIkit, etc) are Apple only. You will have to write your own NSObject and all subclasses if you want to use them (or use the GNUStep library for this).
You can run it on Linux using GNUStep and GCC as the compiler. By the way you will not be able to use a full Cocoa environment as a framework. Have a look at this compatibility list of AppKit
While it's that the language can be compiled and run on multiple other platforms (as others have said), in practice it's almost exclusively used for Mac OS X and iOS development.
Also checkout Cocotron.

Game programming on Objective-C and linux

I'd like to give Objective-C a try in game programming. The problem is I'd need some tools and libraries for this.
First thing that comes into mind I need is the GUI and graphics library.
What choices do I have?
There are Four non Mac implementations of OpenStep/Cocoa type Objective C platforms:
OpenStep/NextStep : Openstep/NeXT support machines only - Discontinued.
p..... can remember name or find it on web - it's out there somewhere ! - Linux
Cocotron - Windows only
GNUStep Linux/Windows
GNUSTep is the way to go for Linux... I mention there others because 2 and 3 are available in source and they can be used to patch holes in code the GNUStep doesn't have and they might.
When it comes to Graphics library - you may have problems because Apple moved away from the old OpenStep APIs and has kept evolving their APIs far faster than the GNUStep people can play catch up. There is no support for the latest graphics libraries such as Core Animation.
As Objective C is C and C++ friendly you can use any of these libraries as is, or by making the Objective C friendly by making a wrapper.
You may or may not want to be Mac compatible and do versions for that so it may not be important.
If you do you might want to do a Linux Wrapper for something like OpenGL if it is missing, which I think it is but have a check yourself....
There are Linux development tools including a project IDE and GUI builder for GNUStep on Linux.
Tony
I believe you're asking for GNUStep.
SDL is a C library which is popular for game programming.
If you're looking for Foundation/AppKit stuff you can also look at Cocotron. I've never tried it though.
Supporting SDL there are Objective-C bindings here. However since Objective-C is a thin OO layer on top of C you can use most of the existing C libs for game development, SDL, Clanlib, etc...