473,545 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2173
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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP10.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.nos pam>
wrote in message news:ex******** *******@TK2MSFT NGP12.phx.gbl.. .
| Willy Denoyette [MVP] wrote:
| > "Gary Nastrasio" <ga***********@ hotmail.com> wrote in message
| > news:%2******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.phx.gbl. ..
"Gary Nastrasio" <ga***********@ hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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*******@Roun dTripInc.com> wrote in message
news:%2******** ********@tk2msf tngp13.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******** ********@tk2msf tngp13.phx.gbl. ..

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@tk2msf tngp13.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5458
by: fareeda | last post by:
hi, I always get an exception "java.lang.UnsatisfiedLinkError" when I use "cout" in my native function. It works - when i use "printf" - other C++ features Here is an example of the native C code I have: ---
0
1869
by: Jeff D. Hamann | last post by:
Sorry for the seemingly novice posting, but I could find a solution for this on the web so far... I've been developing a database using postgresql (and loving it) and have started running into problems with attempting to update records using the ODBC connection. The tables that contain geometric fields are causing the problems. Whenever I...
6
3821
by: Clint Olsen | last post by:
I had this crazy idea to use stdarg macros to copy data in a generic fashion, regardless of type. However, I'm not sure it will work in part due to the ANSI C default argument promotions and the fact that va_arg requires a type to decide how far to advance to subsequent arguments. So, essentially what I want in the variable argument function...
0
1578
by: William Stacey [MVP] | last post by:
Couple questions. Say we are talking about native types such as int, decimal, long, etc. 1) Does XmlSerializer use Invariant culture to serialize and deserialize number types? 2) If wanted to do myself with *.ToString(), could I just use the Invariant culture on all number types and be sure to use same on both sides? Will this work in *all...
12
3547
by: Herby | last post by:
Hi, I am currently reviewing what is required to convert a current MFC, COM server application into a .NET application. The objective is to compile ultimately to clr/safe. So we are seeking a clear migration path for C++\MFC\COM to .NET. We have now chosen to select C++\CLI. We then need to remove the MFC classes such as CString...
3
3937
by: dfranzen | last post by:
Hi *, I'm in the process of porting an ANSI C++ project from a UNIX platform to .NET. After "getting rid of" some platform-specific stuff I managed to compile the first two libraries into mixed assemlies (DLLs) using MSVC8 (VS2005) with the /clr option. However, I get hundreds of linker errors (mostly LNK2028) because assembly B uses native...
0
2020
by: ivan.leben | last post by:
I am writing this in a new thread to alert that I found a solution to the problem mentioned here: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/7970afaa089fd5b8 and to avoid this topic getting lost before people interested in the problem notice it. The important tricks to the solution are two: 1) make the custom classes...
10
6934
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam) {
1
1546
by: ajk | last post by:
Hi I am doing a C++/CLI dll that is supposed to be fully managed code. I was wondering what exactly is the criteria for the DLL to be 100% fully managed and usuable from C#? Do I need to compile using / clr:safe or is /clr enough? The reason I need to know this is that I would like to use pin_ptr<> for some type conversions i.e. bytes to...
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5337
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3457
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1888
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.