Any possible replacements for <windows.h> for macOS? - c

This is such a silly question, but i'm a beginner programmer, and I was following along a youtube tutorial on how to make a digital clock in the C language, and before the main() function there was #include<windows.h>. My computer had an error and after looking it up, I found out that is a file specific to windows? I saw some others said there are ways to "replace" the file or something, but i'm not really sure what to do. Anything helps. Thanks for your time.

Windows and macOS have very different interfaces. Apples uses a generic tool for all its platforms, thus there's no exact equivalent for windows.h in macOS. The closest equivalent I could find was Cocoa. (I'm not an Apple developer, I work mostly on Windows and Linux)
Use the official documentation as a starting point for developing apps on a specific or generic Apple platform. As it is a widely used platform, I expect you will find support on most issues you will encounter given your experience level, on the apple forum.
Also I found this nice tutorial that gives a basic introduction on Apple API's.

Related

Making a GUI simulator in C

Hello StackOverflow Community,
I am writing a MicroMouse Simulator in C language. And I wanted something to visualize the way the maze is being solved like this -- http://www.youtube.com/watch?v=N9TkDgJNJso
I've been researching a way to accomplish this, but I haven't found anything with enough documentation to accomplish my goal.
I don't want to implement this using ASCII symbols, to me it doesn't look professional.
Is there any good GUI interfaces that I could use in C to help me accomplish this? And if so, how would I use it? I don't mind having to code in another language like Java or Python to accomplish my goal.
I saw the video that you want to make. After watching the video I feel you don't need a GUI library for this simulator program.
Here is a list of libraries that you can use.
1.OpenGL This is a 3D graphics API which also can be used for 2D and can be used with both c/c++
2.SDL This library is easy to understand for a beginner. For your program this library is better and can be used with both c/c++.
3.winBGIm This is same as the graphics.h that you found and can be used both c/c++ but it is only for windows.
If you are looking for GUI library then here's a short list.
1.GTK This is written in c and is a popular GUI library for c. You can find a GUI editor for gtk forms called glade which enables quick & easy development of user interfaces.
2.WxWidgets This is written in c++ so you have to use c++ rather than c.
3.FLTK
There are many more libraries besides these which you can find in google. You said
I do not mind having to code in another language like Java or Python to accomplish my goal.
Then for java you can use swing and If you are windows developer then use the windows form application in visual c++; then development of your program will be very easy.
SDL is one of candidate for C in order to make GUI Simulation. Lazyfoo is one of the best site I found for beginner.
SDL is strongly portable. It's written in C and there're a lot of documentation and tutorials.

Are there expert system shells for the mac?

Recently I had an interesting AI discussion with a friend, and I became curious about expert systems.
After spending 2 hours on Google I couldn't find anything useful to get started with. Does anyone know an expert system shell which runs on the mac and is documented well enough so a beginner can comprehend and use it to build an expert system?
I think playing with them is a good way to learn how they work, how the knowledge is modeled.
CLIPS runs with Mac OS X: http://clipsrules.sourceforge.net/. There's online documentation available as well as PDFs. You can glance through the User's Guide to see if it's something of interest to you.

Mono with C# - Converting a WinForms interface over to Cocoa? (or whatever the default OS X interface is)

I have a C# app that I've managed to get working with Mono and running on OS X. The application itself runs just fine, but it doesn't really look all that good when run on OS X. The button fonts look jagged, and many of the default features that are there for the Windows 7 version aren't present. To me it sort of looks like a Win98 application with an OS X top border taped to it.
I'm looking into possibly learning Objective-C so that I can write 'proper' OS X apps, but for the moment I'd like to be able to get my projects working on an Apple without having them look Frankensteined together.
Is it possible to convert a WinForms app over to Cocoa? Is Cocoa the correct interface to use?
If possible, what's the best way to go about it, and do any of you know of a good tutorial/writeup on the process to get me started? It'd be nice to see something that actually shows the process being done. I learn far more from example code along with a short explanation than I do from a generic article.
Thanks again!
If you want to create a native looking OSX application, you are correct that you want to use Cocoa. If you still want to use C#, you can use MonoMac.
MonoMac allows you to build your GUI natively on OSX (in fact, using the Interface Builder shipped by Apple), but allows you to write your app in .Net/C#. This way you can continue to use your existing application logic and only have to change the GUI code.
It's pretty much universally true that a ported app will always look like a ported app. Even large companies with huge budgets can't pull off anything better (I cite Adobe - what a mess).
Slapping a Mac face on a Windows app port will show its seams. If you want the application to behave like a native application (and take advantage of the performance-related goodies the platform offers), the absolute best approach is to use the architectural documentation, specs, and requirements I know you have - conscientious developer that you are - to adapt the design to the native platform. That's the Cocoa Frameworks (the API), which are written in Objective-C (the language).
There's quite simply no other path that doesn't end with a crappy-looking port that's riddled with bugs and behavioral problems born of the porter's insufficient familiarity with the target platform. This isn't just limited to Mono/C#-to-Cocoa/Obj-C. The opposite is just as true. Even Java-for-PlatformA-to-Java-for-PlatformB ports of desktop apps suffer these problems. Start with a solid architecture and build for the platform if you want the best user experience.
That said, you're already a step ahead by realizing this and wanting to do better. Bravo! :-) Though I don't know of any tutorials for this path, I'd suggest even that's not the correct approach since you indicated you're looking for quality. Avail yourself of the many Cocoa books and many more online communities (like this one) and learn the platform before committing to your Cocoa-adapted architecture and code base.
Update based on comment debate
To be clear: I'm not saying there's no way or that there's no tool out there that makes it possible. There're actually plenty I've seen but don't recall and won't bother googling. My point remains: the OP is concerned with quality of native appearance (and I assume behavior and possibly performance) and porting tools / translation layers don't achieve this due to inherent differences in the platform's architecture and user experience idioms. The OP suspects it might be best to learn the platform and build specifically for it and I'm agreeing. Your opinion may vary. Have at it.

code helper for c programming

Are there any plugins for visual studio (any version) or any other ide that can show you the standard library function prototypes and their (examples) , return etc for the standard c library... much like the java code helper found in eclipse if I am not mistaken (I am not a java developer but I think I saw something similar to what I described).
note: I know I can use google or msdn but I am asking about other alternatives.
Visual Assist X is by far the best C/C++ improvement for Visual Studio.
Edit in response to userHel's comment:
I'll give it a shot. but how come nobody came up with a free version
Probably because it's really hard to do well. You practically need an entire compiler just to parse C++ sufficiently to give the kinds of features VA-X does. At the other end of the stack, you would also need an almost flawless integration with Visual Studio. Just imagine what's in between...
This is where firstborn selling comes in...
KDevelop4 has good C++ analysis support which is constantly improving, including features which I think were inspired by VAX. I haven't used VAX so I can't comment on feature parity, but it has all the C++ features I need. Of note is the tooltip when holding the mouse over an identifier, which gives type info as well as links to the definition (and declaration if available).
For linux development, the man pages are excellent. I'd like to know of something similar for Windows.

Getting Started with C and Objective-C

I am eventually wanting to program in Objective-C to write programs for OS X and possibly the iPhone. I do not have any direct experience with C and I come from a web programming background. I am much more familiar with java syntax than C and Objective C.
I am just looking for suggestions on how to get started. It looks like I need to just start with C (I do not yet have a Mac computer powerful enough for programming, so it would be nice to start with C on the Windows platform anyway (information about programming environments would be helpful too, I am used to eclipse)). I am just looking for book recommendations, online tutorials or any other pointers to keep in mind. Keep in mind though that my end goal is to work with Objective-C, so is there anything I need to keep in mind when learning C, anything to watch out for, etc. Thanks for any input.
Update: The reason I am thinking I need to learn C first is that most of the tutorials that I have come across so far for Objective-C assume you already understand C syntax, which I do not fully. Are there better tutorials out there for me?
I don't entirely agree with unwind who says "C and Objective-C are different languages". Objective-C is a strict superset of C.
Of course he knows that - his point was that you don't need to completely master C before progressing onto Objective-C. I'll second that (and hopefully have clarified it).
But I do think it's worth getting some basics with C first, as most introductory texts on Objective-C will assume a basic knowledge.
I don't have any recommendations on that myself, but probably most internet based tutorials will be sufficient for that purpose (remember, you're not trying to master it at this stage). If you want to take it seriously, then "The C Programming Language" by K&R is the classic text.
When you you can do some basic hello world programs in C, and understand the type system, pointers and stuff - then pick up a copy of "Cocoa Programming for Mac OS X", by Aaron Hillegass. This is a book about Cocoa that covers Objective-C along the way, but it one of the best presented coverages of the language. It will assume you are coding on a Mac (it's in the context of Cocoa after all). You may be able to follow the pure language stuff using GCC on Windows, but I wouldn't recommend it.
If you're going to be working on a Mac eventually, then best to do it at this stage, IMHO. You say you don't have a Mac "powerful enough for programming", but anything that can run OS X would be fine to get your started.
If you know java, obj-c will be easy for you (java was influenced a lot by obj-c.) Apple has great documentation, you can start here. I don't think you need to learn C before learning obj-c (sorry Joel).
You can use obj-c on windows if you get gcc. Also check out cocotron:
The Cocotron is an open source project
which aims to implement a
cross-platform Objective-C API similar
to that described by Apple Inc.'s
Cocoa documentation. This includes the
AppKit, Foundation, Objective-C
runtime and support APIs such as
CoreGraphics and CoreFoundation.
With all the buzz about iPhone development, there are now dozens of obj-c books. Not sure how good they are, but a classic that I would suggest is Cocoa Programming from Mac OSX by Aaron Hillegass.
Programming in Objective-C by Stephen Kochan is what you want. It assumes no programming experience but doesn't hold you back if you do and introduces the whole thing, C with the Objective-C superset, as a complete package. I read the first half of Kochan (the second half gets into Cocoa) and now I'm working on Cocoa Programming for Mac OS X (3rd Edition) by Aaron Hillegass and reading Kochan was a massive help. Those two are a "one-two punch" that will get you going in no time.
Have a C and Objective-C reference handy as Apple's docs of C in XCode pretty much sucks from what I've seen so far. K&R's C text is like the Encyclopedia Brittanica of C and, just like a set of encyclopedias, isn't for everyone. I've just been Googling for references and generally find what I need on the web since C is so ubiquitous.
You'll burn through a couple of books before you find the set that best fits you, but you simply can't go wrong with Kochan and Hillegass for Objective-C and Cocoa. By the time you finiah the first couple chapters of Hillegass, you'll want to (and be able to) start writing some stuff on your own.
There is a recent blog-entry at Tuaw:
http://www.tuaw.com/2009/01/15/starting-out-with-objective-c/
4 guides about getting started with Objective-C, which helped me quite a lot when I started developing in Xcode. You should take a look at this:
http://cocoadevcentral.com/
http://developer.apple.com/iphone/index.action
http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/
http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/mobilehig/Introduction/Introduction.html#//apple_ref/doc/uid/TP40006556-CH1-SW1
I'd say that it's better to learn C first. be sure to approach it like what it is: a structured machine language.
when you feel comfortable on it (no need to really master it), go on to Objective C, where you'll rediscover several things familiar from Java, but knowing the C infrastructure will make more apparent when they're similar but not equivalent.
it's very important not to learn a language using what you already know as a 'metaphor' for the new. always try to pretend you didn't know anything before.
I don't know what you mean by a Mac powerful enough to do programming on (any Mac should do), but get yourself something at least marginally useful as a development system soon. (You may well have the development system on one of the CDs that came with your Mac, or alternatively you can download it from Apple.)
The sooner you get Xcode working, the sooner you'll be comfortable with it.
I have recently started to learn programming for the Iphone and tried many differenet books until i found these helped me the most (I would also strongly recomenned getting a mac since the Xcode is the way to go when coding for Iphone):
Apress: Learn C on the Mac (To
get the initial C going)
Apress: Learn Objective-C on the Mac
(Learn Objective-C based on your
understanding of C)
Apress: Learn Cocoa for the mac
(learn apples way of building
applications, greatly helps when
going over to Iphone however you can
go straight to the iphone if you
like)
Apress: Beginning Iphone
development... (The final book,
and essential tool)
To note all these books have the same author and thus the traceability is great! The books have crossreferences between each other that really helps.
Agreeing with others, I found Cocoa Programming for Mac OSX - Hillegass
a great intro to Objective-C, the Cocoa framework and whole Apple way of doing things.
You can run Objective-C on any Linux or Windows box too although of course you won't have access to all the Apple libraries eg. NS (afaik). These frameworks are really the whole point of Objective-C, and the real reason it still exists given C++ and C# came later and are more or less languages designed around themselves (as opposed to Objective-C which is a strict superset of C).
Apart from pointers, I think you can get by without learning all the intricacies and close-to-the-metal aspects of C, although any and all C you can digest always helps.

Resources