fatal Error C1004

Can't find a single error but its not compiling

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 2593 Views - Last Post: 16 December 2010 - 12:12 PM Rate Topic: -----

#1 sreyan32  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 15-December 10

fatal Error C1004

Posted 15 December 2010 - 10:34 AM

#include<windows.h>
int_stdcall WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,
					 LPSTR lpszCmdLine,int nCmdShow)

{
	MessageBox(0,"Hello!","Title",0);
	return (0);
}


------------------------------------------------------------------------
I can't find any error with the following code but it refuses to compile.
Getting the following error message-:

--------------------Configuration: WinProj1 - Win32 Debug--------------------
Compiling...
HelloWorld.c
c:\program files\microsoft visual studio\vc98\include\unknwn.h(301) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

HelloWorld.obj - 1 error(s), 0 warning(s)

This post has been edited by ishkabible: 15 December 2010 - 10:43 AM
Reason for edit:: please post code in code tags!!


Is This A Good Question/Topic? 0
  • +

Replies To: fatal Error C1004

#2 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: fatal Error C1004

Posted 15 December 2010 - 10:49 AM

sometimes i have issues where i copy and past some stuff and there are little hidden charters that are either in Unicode or (what i believe to the case here) you copied in an end of file charter. if it's an end of line charter then rewrite that line charter by charter and delete the old one. if it's in Unicode that copy and past it into an editor that dose not support Unicode. windows notepad only supports ASCII and all Unicode charters will show up as question marks. take out the question marks and paste it back in your code.
Was This Post Helpful? 0
  • +
  • -

#3 sreyan32  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 15-December 10

Re: fatal Error C1004

Posted 15 December 2010 - 10:58 AM

View Postsreyan32, on 15 December 2010 - 09:34 AM, said:

#include<windows.h>
int_stdcall WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,
					 LPSTR lpszCmdLine,int nCmdShow)

{
	MessageBox(0,"Hello!","Title",0);
	return (0);
}


------------------------------------------------------------------------
I can't find any error with the following code but it refuses to compile.
Getting the following error message-:

--------------------Configuration: WinProj1 - Win32 Debug--------------------
Compiling...
HelloWorld.c
c:\program files\microsoft visual studio\vc98\include\unknwn.h(301) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

HelloWorld.obj - 1 error(s), 0 warning(s)

I already wrote the entire code by hand-every line.And on top of that when you open the code in notepad or wordpad it does not show any question marks or weird symbols.Tell me can my compiler be corrupted????
Was This Post Helpful? 0
  • +
  • -

#4 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: fatal Error C1004

Posted 15 December 2010 - 11:01 AM

probably not your compiler. lets see all your code, you may be missing a brace something that the compiler isn't pointing out. the chance of a compiler being crupted and still spitting out a reasonable error is slim to none.

edit: ya it's most likely the spacing mentioned below. i should have seen that, i never use calling conventions and thought it was some typedef you had made.

This post has been edited by ishkabible: 15 December 2010 - 11:19 AM

Was This Post Helpful? 0
  • +
  • -

#5 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: fatal Error C1004

Posted 15 December 2010 - 11:15 AM

There should be a space between int and _stdcall.

int _stdcall

Was This Post Helpful? 1
  • +
  • -

#6 Guest_sreyan32*


Reputation:

Re: fatal Error C1004

Posted 15 December 2010 - 12:32 PM

View Postishkabible, on 15 December 2010 - 10:01 AM, said:

probably not your compiler. lets see all your code, you may be missing a brace something that the compiler isn't pointing out. the chance of a compiler being crupted and still spitting out a reasonable error is slim to none.

edit: ya it's most likely the spacing mentioned below. i should have seen that, i never use calling conventions and thought it was some typedef you had made.


Yes i have also tried that but it just does'nt compile for god sakes.Giving a space makes stdcall appear in blue i guess that the right syntax but that still does'nt make my programme compile.And this is all my code it's my first windows programme in C.
Was This Post Helpful? 0

#7 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: fatal Error C1004

Posted 15 December 2010 - 01:43 PM

post the whole source, my bet is your missing a brace somewhere. sometimes the compiler doesn't perfectly figure out what you did wrong.
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: fatal Error C1004

Posted 15 December 2010 - 01:48 PM

You shouldn't even need the _stdcall.

What development environment/compiler are you using? It looks like MS Visual C++, so what version is it? What kind of project did you create?

My best guess is there's something funky about your project settings, but I would need more info to investigate.
Was This Post Helpful? 1
  • +
  • -

#9 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: fatal Error C1004

Posted 15 December 2010 - 04:01 PM

Looks like it should be a double underline before stdcall.

#define WINAPI __stdcall

Was This Post Helpful? 0
  • +
  • -

#10 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: fatal Error C1004

Posted 15 December 2010 - 04:17 PM

Like JackOfAllTrades I believe it's your project settings.

Does it build okay if you do a standard "Hello World" program?

#include <stdio.h>

int main()
{
    puts("Hello world!");

    return 0;
}



If this builds it's been set up as a console project. Still not confirmation, as you may be attempting to create a static or dynamic library.

Alternatively, if you really want to be sure and using Visual Studio follow these instructions to confirm exactly what your settings are. :)
Was This Post Helpful? 0
  • +
  • -

#11 Guest_sreyan32*


Reputation:

Re: fatal Error C1004

Posted 16 December 2010 - 10:10 AM

View PostButchDean, on 15 December 2010 - 03:17 PM, said:

Like JackOfAllTrades I believe it's your project settings.

Does it build okay if you do a standard "Hello World" program?

#include <stdio.h>

int main()
{
    puts("Hello world!");

    return 0;
}



If this builds it's been set up as a console project. Still not confirmation, as you may be attempting to create a static or dynamic library.

Alternatively, if you really want to be sure and using Visual Studio follow these instructions to confirm exactly what your settings are. :)

This is my entire source code posted. I am using Microsoft Visual C++ 6.0. I created a Win32Application Project(named WinProj1).And then set it to an empty project. I then created a C++ Source file called WinProj1.c then typed the code that you see.No matter what I do it does not compile I always get fatal error C1004.Plz help.
Was This Post Helpful? 0

#12 jimblumberg  Icon User is offline

  • member icon


Reputation: 4002
  • View blog
  • Posts: 12,346
  • Joined: 25-December 09

Re: fatal Error C1004

Posted 16 December 2010 - 10:14 AM

Please post your code again.

Jim
Was This Post Helpful? 0
  • +
  • -

#13 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: fatal Error C1004

Posted 16 December 2010 - 10:25 AM

Quote

Microsoft Visual C++ 6.0

THAT is going to make it difficult to reproduce this. That is from 1998, and not readily available for most. Why are you using such an old compiler/IDE?
Was This Post Helpful? 0
  • +
  • -

#14 Guest_sreyan32*


Reputation:

Re: fatal Error C1004

Posted 16 December 2010 - 10:32 AM

View PostJackOfAllTrades, on 16 December 2010 - 09:25 AM, said:

Quote

Microsoft Visual C++ 6.0

THAT is going to make it difficult to reproduce this. That is from 1998, and not readily available for most. Why are you using such an old compiler/IDE?

Because thats what i have I do not wnat to download another IDE.
Tell me,I want to write a programme in C which when executed displays "Hello World" in a message box with an OK button at the end how do I do it??????

My Code that I am using is-:
#include<windows.h>
int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                     LPSTR lpszCmdLine,int nCmdShow)

{ MessageBox(0,"Hello World !","Title",0);
 
 return (0);
}


Do I need to create and add any header files to my project because I am not adding any.Plz tell me because I am a beginner to VC++.

This post has been edited by JackOfAllTrades: 16 December 2010 - 10:35 AM
Reason for edit:: Added code tags...AGAIN!

Was This Post Helpful? 0

#15 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: fatal Error C1004

Posted 16 December 2010 - 10:37 AM

Quote

Because thats what i have I do not wnat to download another IDE.

Well that seems a pretty stupid and hard-headed reason, but whatever. You're making your life harder, especially if you're looking for help.

So, if you're heeding our advice, WHY is _stdcall still there and/or wrong, as pointed out above?
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2