472,096 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

Using /clr:safe and Native Types

If I compile with /clr:safe, which is exactly meant by saying I can't
use "Native Types" in my code? Is a native type something such as
float, short, or int?

Thanks,

Gary
Jan 19 '06 #1
8 2082
Gary Nastrasio schrieb:
If I compile with /clr:safe, which is exactly meant by saying I can't
use "Native Types" in my code? Is a native type something such as
float, short, or int?


No. AFAIK, this types will be mapped to System::Single, System::Int16
and System::Int32

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 19 '06 #2

"Gary Nastrasio" <ga***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
| If I compile with /clr:safe, which is exactly meant by saying I can't
| use "Native Types" in my code? Is a native type something such as
| float, short, or int?
|
| Thanks,
|
| Gary

No, native types are types like pointers (int* blabla) user defined native
types (class, struct...) C++ intrinsic types like wchar_t etc..
Primitive types like int, short, float, double ... are directly mapped to
the corresponding CLR types System::Int32, Int16, Float, Double ..
Willy.
Jan 19 '06 #3
Willy Denoyette [MVP] wrote:
"Gary Nastrasio" <ga***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
If I compile with /clr:safe, which is exactly meant by saying I can't
use "Native Types" in my code? Is a native type something such as
float, short, or int?

Thanks,

Gary


No, native types are types like pointers (int* blabla) user defined
native types (class, struct...) C++ intrinsic types like wchar_t etc..
Primitive types like int, short, float, double ... are directly
mapped to the corresponding CLR types System::Int32, Int16, Float,
Double ..


wchar_t maps to System::Char in managed C++, so it's fine for /clr:safe as
well as the other intrinsic types you mentioned.

-cd
Jan 20 '06 #4

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:ex***************@TK2MSFTNGP12.phx.gbl...
| Willy Denoyette [MVP] wrote:
| > "Gary Nastrasio" <ga***********@hotmail.com> wrote in message
| > news:%2****************@TK2MSFTNGP10.phx.gbl...
| >> If I compile with /clr:safe, which is exactly meant by saying I can't
| >> use "Native Types" in my code? Is a native type something such as
| >> float, short, or int?
| >>
| >> Thanks,
| >>
| >> Gary
| >
| > No, native types are types like pointers (int* blabla) user defined
| > native types (class, struct...) C++ intrinsic types like wchar_t etc..
| > Primitive types like int, short, float, double ... are directly
| > mapped to the corresponding CLR types System::Int32, Int16, Float,
| > Double ..
|
| wchar_t maps to System::Char in managed C++, so it's fine for /clr:safe as
| well as the other intrinsic types you mentioned.
|

Very true, but it's usage is somewhat limitted.

wchar_t wch = 'A'; // is OK
but...
wchar_t* wsp = L"Test";
wchar_t wch[] = L"123";
are not..
Willy.

Jan 20 '06 #5
Willy Denoyette [MVP] wrote:
"Carl Daniel [VC++ MVP]"
wchar_t maps to System::Char in managed C++, so it's fine for
/clr:safe as well as the other intrinsic types you mentioned.


Very true, but it's usage is somewhat limitted.

wchar_t wch = 'A'; // is OK
but...
wchar_t* wsp = L"Test";
wchar_t wch[] = L"123";
are not..


True that.

-cd
Jan 20 '06 #6
> | If I compile with /clr:safe, which is exactly meant by saying I can't
| use "Native Types" in my code? Is a native type something such as
| float, short, or int? No, native types are types like pointers (int* blabla) user defined native
types (class, struct...) C++ intrinsic types like wchar_t etc..
If I read this literally it sounds like one can't do any custom object
oriented programming in /clr:safe mode. After all, if a user-defined class
is a native type, and native types aren't allowed in /clr:safe mode, I can
conclude I can't define my own classes in /clr:safe mode (based on the two
statements above, the bottom one being a response for the top one).

Or are you making a distinction here between 'class' and 'ref class'?

[==P==]

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Gary Nastrasio" <ga***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
| If I compile with /clr:safe, which is exactly meant by saying I can't
| use "Native Types" in my code? Is a native type something such as
| float, short, or int?
|
| Thanks,
|
| Gary

No, native types are types like pointers (int* blabla) user defined native
types (class, struct...) C++ intrinsic types like wchar_t etc..
Primitive types like int, short, float, double ... are directly mapped to
the corresponding CLR types System::Int32, Int16, Float, Double ..
Willy.

Jan 20 '06 #7

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
|> | If I compile with /clr:safe, which is exactly meant by saying I can't
| > | use "Native Types" in my code? Is a native type something such as
| > | float, short, or int?
|
| > No, native types are types like pointers (int* blabla) user defined
native
| > types (class, struct...) C++ intrinsic types like wchar_t etc..
|
| If I read this literally it sounds like one can't do any custom object
| oriented programming in /clr:safe mode. After all, if a user-defined class
| is a native type, and native types aren't allowed in /clr:safe mode, I can
| conclude I can't define my own classes in /clr:safe mode (based on the two
| statements above, the bottom one being a response for the top one).
|
| Or are you making a distinction here between 'class' and 'ref class'?
|

Yep, this only applies to C++ class and struct, that's what I meant with ...
user defined native types ..
Sorry for the confusion.

Willy.


Jan 20 '06 #8
Willy,

No apology needed, I learned something new! I should be thanking you... : )

[and that rhymed...lol]

[==P==]

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
|> | If I compile with /clr:safe, which is exactly meant by saying I can't
| > | use "Native Types" in my code? Is a native type something such as
| > | float, short, or int?
|
| > No, native types are types like pointers (int* blabla) user defined
native
| > types (class, struct...) C++ intrinsic types like wchar_t etc..
|
| If I read this literally it sounds like one can't do any custom object
| oriented programming in /clr:safe mode. After all, if a user-defined
class
| is a native type, and native types aren't allowed in /clr:safe mode, I
can
| conclude I can't define my own classes in /clr:safe mode (based on the
two
| statements above, the bottom one being a response for the top one).
|
| Or are you making a distinction here between 'class' and 'ref class'?
|

Yep, this only applies to C++ class and struct, that's what I meant with
...
user defined native types ..
Sorry for the confusion.

Willy.

Jan 20 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by fareeda | last post: by
6 posts views Thread by Clint Olsen | last post: by
reply views Thread by William Stacey [MVP] | last post: by
12 posts views Thread by Herby | last post: by
1 post views Thread by ajk | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.