Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code 
Author Message
 Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code

Hi all,
I have Microsoft Visual C++.NET (Standard Edition) in my
Windows XP Home Edition PC.  I got a fatal error C1010:
unexpected end of file while looking for precompiled
header directive, when I tried to build the following
code of the Managed C++ Application in my PC:

/////////***Mixing1-Hello.cpp***//////////
#using <mscorlib.dll>
using namespace System;

#include "stdio.h"
void ManagedFunction()
{
        printf("Hello, I'm managed in this section\n");

Quote:
}

#pragma unmanaged
UnmanagedFunction()
{
        printf("Hello, I am unmanaged through the wonder
of IJW!\n");
        ManagedFunction();
Quote:
}

#pragma managed
int main()
{
        UnmanagedFunction();
        return 0;
Quote:
}

//////////////////////////////////
Please help and advise me what is wrong with this set of
codes and how to correct the error.
Thanks in advance,
Scott  Chang
============================================
P.S.  The same fatal error C1010 occurred to the
following the mixing Managed C++ and Unmanaged C++
application too:

//////****Mixing2-Howdy.cpp****/////
#using <mscorlib.dll>
#include <vcclr.h>
using namespace System;

class CppClass {
public:
   gcroot<String*> str;   // can use str as if it were
String*
   CppClass() {}

Quote:
};

int main() {
   CppClass c;
   c.str = new String(S"Howdy");
   Console::WriteLine( c.str ); // no cast required
Quote:
}

/////////////////////////////////
Please tell me why the "Fatal Error C1010" happened to
both "Mixing1-Hello.cpp" and "Mixing2-Howdy.cpp".
Thanks again,
Scott  Chang


Wed, 31 Aug 2005 21:57:17 GMT  
 Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code


Quote:
> Hi all,

Greetings.

Quote:
> I have Microsoft Visual C++.NET (Standard Edition) in my
> Windows XP Home Edition PC.  I got a fatal error C1010:
> unexpected end of file while looking for precompiled
> header directive, when I tried to build the following
> code of the Managed C++ Application in my PC:

> /////////***Mixing1-Hello.cpp***//////////
> #using <mscorlib.dll>
> using namespace System;

> #include "stdio.h"

[Ordinary code cut.]
...
Quote:
> //////****Mixing2-Howdy.cpp****/////
> #using <mscorlib.dll>
> #include <vcclr.h>

[Ordinary code cut.]

Quote:
> Please tell me why the "Fatal Error C1010" happened to
> both "Mixing1-Hello.cpp" and "Mixing2-Howdy.cpp".

The compiler was told, via settings in your
project, to use a precompiled header in lieu
of compiling everything up to and including a
particular #include directive.  That directive
was not found, so the error you see was given.

Either turn off precompiled header usage for
those sources or put the appropriate #include
at the head of the file.  You can see what
that would be by examining compile settings
for that file.  Typically, (because it is
setup this way and not changed), this line:
  #include "stdafx.h"
is required.

You may want to consider putting #include's
used throughout your project into whatever
header is used precompiled.  This can speed
up your compilations quite a bit.

Quote:
> Thanks again,

You're welcome.

--
-Larry Brasfield
(address munged, s/sn/h/ to reply)



Wed, 31 Aug 2005 22:22:47 GMT  
 Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code
Hi Larry, Thanks for your help and adsvice.

(1) I added #include "stdafx.h" to the Mixing1-Hello.cpp
program and built it in my PC - It worked perfactly.

(2) I added #include "stdafx.h" to the Mixing2-Howdy.cpp
program and built it in my PC (as Mix2-Hi.cpp) - I got 7
errors listed below:

------ Build started: Project: Mix2-Hi, Configuration:
Debug Win32 ------

Compiling...

Mix2-Hi.cpp

Mix2-Hi.cpp(24) : error C2871: 'System' : a namespace with
this name does not exist

Mix2-Hi.cpp(28) : error C2143: syntax error : missing ';'
before '<'

Mix2-Hi.cpp(28) : error C2501: 'CppClass::gcroot' :
missing storage-class or type specifiers

Mix2-Hi.cpp(28) : error C2238: unexpected token(s)
preceding ';'

Mix2-Hi.cpp(34) : error C2039: 'str' : is not a member
of 'CppClass'

        Mix2-Hi.cpp(26) : see declaration of 'CppClass'

Mix2-Hi.cpp(34) : error C2061: syntax error :
identifier 'String'

Mix2-Hi.cpp(34) : fatal error C1190: managed targeted code
requires '#using <mscorlib.dll>' and '/clr' option

Build log was saved at "file://c:\C++Projects\Mix2-
Hi\Debug\BuildLog.htm"

Mix2-Hi - 7 error(s), 0 warning(s)

---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped
************************************************8
I do not know how to correct them - I am new in C++ and
Visual C++.NET programmings and I do not know how to put
the appropriate #include at the head of the file as you
instructed for the Minxing2-Howdy.cpp case. Please help me
again and tell me how to solve this new problem.
Thanks,
Scott  Chang



Fri, 02 Sep 2005 23:26:58 GMT  
 Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code
--------------------
| Content-Class: urn:content-classes:message




| Subject: Re: Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++
Code
| Date: Mon, 17 Mar 2003 07:26:58 -0800
| Lines: 55

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcLsmaaXZT8yl9vfSEeEoUnPI5giqA==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.vc
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| Path: cpmsftngxa06!cpmsftngxa08.phx.gbl
| Xref: cpmsftngxa06 microsoft.public.dotnet.languages.vc:21427
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| Hi Larry, Thanks for your help and adsvice.
|
| (1) I added #include "stdafx.h" to the Mixing1-Hello.cpp
| program and built it in my PC - It worked perfactly.
|
| (2) I added #include "stdafx.h" to the Mixing2-Howdy.cpp
| program and built it in my PC (as Mix2-Hi.cpp) - I got 7
| errors listed below:
|
| ------ Build started: Project: Mix2-Hi, Configuration:
| Debug Win32 ------
|
| Compiling...
|
| Mix2-Hi.cpp
|
| Mix2-Hi.cpp(24) : error C2871: 'System' : a namespace with
| this name does not exist
|
| Mix2-Hi.cpp(28) : error C2143: syntax error : missing ';'
| before '<'
|
| Mix2-Hi.cpp(28) : error C2501: 'CppClass::gcroot' :
| missing storage-class or type specifiers
|
| Mix2-Hi.cpp(28) : error C2238: unexpected token(s)
| preceding ';'
|
| Mix2-Hi.cpp(34) : error C2039: 'str' : is not a member
| of 'CppClass'
|
|         Mix2-Hi.cpp(26) : see declaration of 'CppClass'
|
| Mix2-Hi.cpp(34) : error C2061: syntax error :
| identifier 'String'
|
| Mix2-Hi.cpp(34) : fatal error C1190: managed targeted code
| requires '#using <mscorlib.dll>' and '/clr' option
|
| Build log was saved at "file://c:\C++Projects\Mix2-
| Hi\Debug\BuildLog.htm"
|
| Mix2-Hi - 7 error(s), 0 warning(s)
|
| ---------------------- Done ----------------------
|
|     Build: 0 succeeded, 1 failed, 0 skipped
| ************************************************8
| I do not know how to correct them - I am new in C++ and
| Visual C++.NET programmings and I do not know how to put
| the appropriate #include at the head of the file as you
| instructed for the Minxing2-Howdy.cpp case. Please help me
| again and tell me how to solve this new problem.
| Thanks,
| Scott  Chang
|

You may wont to put the #include "stdafx.h" statement on the first line in
the cpp file and not after the one with #using <mscorlib.dll>
e.g.

#include "stdafx.h"

#using <mscorlib.dll>
#include <vcclr.h>
using namespace System;

In this case the order makes a difference.
--
Silviu Guea, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Sat, 03 Sep 2005 02:57:38 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Debugging mixed managed/unmanaged c++ code

2. mixing unmanaged and managed C++

3. Try to get DirectX started in the Mixed Managed and Unmanaged C++ Programming

4. Mixing Managed and Unmanaged C++

5. Referencing data from unmanaged code to managed code in C++ Wrapper class

6. Debugging into managed c++ DLL that is being used by unmanaged code

7. Managed c++ with unmanaged code Linking problem...

8. C++ Dot net: calling managed method from unmanaged code

9. Possible vc++ bug: using c++ references to managed objects in unmanaged code

10. problem of unmanaged exception in managed code C++

11. managed C++ wrapper around unmanaged C++ classes: causing StackOverflow exception

12. Managed C++ call unmanaged DLL error

 

 
Powered by phpBB® Forum Software