3

I'm trying to learn C++ and I'm not a fan of Windows, therefore using Visual Studio isn't ideal. I have Xcode on my Mac though.

I wrote a program in C++ in Visual Studio and it works fine. When I transfer the code to Xcode (using the c++ tool environment) It still works fine but it doesn't like the top #include statement. Why?

#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <time.h>

Also it still doesn't like it if I use <...> instead of "..." It doesn't affect my current program that I can see.

Basically I'm wondering what its importance is? and do I or will I need it in the future?

Cœur
  • 37,241
  • 25
  • 195
  • 267
binary101
  • 1,013
  • 3
  • 23
  • 34
  • remove #include "stdafx.h" its visual studio precompiled header http://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-studio – SRN Oct 25 '12 at 18:01

4 Answers4

5

stdafx.h is a windows (visual studio) related header file. Just remove it.

Guillaume
  • 1,022
  • 1
  • 9
  • 17
1

stdafx.h is Visual Studio's precompiled header helper. Just remove it. Xcode has its own way of doing precompiled headers.

Cœur
  • 37,241
  • 25
  • 195
  • 267
rubenvb
  • 74,642
  • 33
  • 187
  • 332
0

just like this

 #include <stdlib.h>
 #include <iostream>
 #include <time.h>

stdafx.h only exits in vs

Bot
  • 11,868
  • 11
  • 75
  • 131
lovaya
  • 445
  • 3
  • 3
0

After taking 2 seconds to google "stdafx" it appears it is a header file generated by visual studio. Try removing it. Also try searching for things.

Jake Sellers
  • 2,350
  • 2
  • 21
  • 40
  • I didn't down vote it, i don't have the correct reputation yet. I do however appreciate your comment, but sometimes i just want a quick answer and this site has yet to let me down. – binary101 Oct 25 '12 at 18:25