I'm having a problem compiling a managed extensions project that has one set
of functions that is supposed to be unmanaged.
I've found out how to set the properties of a single file, in which way I
can set the /clr option on a file level, which is good.
But when I add the unmanaged code as a .c file, I get
Words fatal error C1190: managed targeted code requires '#using
<mscorlib.dll>' and '/clr' option
only if the /clr option for the file is set to true.
But if I add them as a .cpp file, I get that same error if the /clr option
is set to false.

Could I not add them as a .cpp file with /clr off?


Also I get the linker warning
nochkclr.obj : warning LNK4099: PDB 'libc.pdb' was not found with
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\nochkclr.obj' or
at '...\libc.pdb'; linking object as if no debug info

What's the resolution for this?

Re: managed extensions by Jochen

Jochen
Mon Oct 18 00:20:33 CDT 2004

Bonj wrote:

> Could I not add them as a .cpp file with /clr off?

To disable CLR for a specific file use:


#ifdef __MANAGED
#pragma unmanaged
#endif

// unmanaged code

#ifdef __MANAGED
#pragma managed
#endif


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Re: managed extensions by Jochen

Jochen
Mon Oct 18 00:21:37 CDT 2004

Bonj wrote:

> Could I not add them as a .cpp file with /clr off?

To disable CLR for a specific file use:


#ifdef __MANAGED
#pragma unmanaged
#endif

// unmanaged code

#ifdef __MANAGED
#pragma managed
#endif


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Re: managed extensions by Bonj

Bonj
Mon Oct 18 03:25:03 CDT 2004

Thanks very much
This doesn't solve the issue I describe, but I think it probably bypasses it.

I'm still curious as to why .c files can be compiled with the 'Assembly
support (/clr)' switch off, whereas C++ files can't. Perhaps it just *wants*
you to write managed code.


Re: managed extensions by adebaene

adebaene
Mon Oct 18 03:29:54 CDT 2004

"Bonj" <benjtaylor at hotpop d0t com> wrote in message news:<#fKlLXKtEHA.3872@TK2MSFTNGP15.phx.gbl>...
> I'm having a problem compiling a managed extensions project that has one set
> of functions that is supposed to be unmanaged.
> I've found out how to set the properties of a single file, in which way I
> can set the /clr option on a file level, which is good.
> But when I add the unmanaged code as a .c file, I get
> Words fatal error C1190: managed targeted code requires '#using
> <mscorlib.dll>' and '/clr' option
> only if the /clr option for the file is set to true.
> But if I add them as a .cpp file, I get that same error if the /clr option
> is set to false.
>
> Could I not add them as a .cpp file with /clr off?

You can use /clr option only with cpp files (or files compiled with
/Tp). You may also look at #pragma managed and #pragma unmanaged

Arnaud
MVP - VC