473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C++/CLI and fixed size buffers

From the same C++ source code, I'm attempting to generate both an unmanaged
DLL and a managed assembly. This will eliminate interop as the calling code
is slowly migrated to .NET.
However, C++ native compilation allows fixed size buffers (e.g. char
pathName[128]) which we've used to represent a memory mapped file, and I
can't find out how to implement the same in C++/CLI
i.e.

#ifdef _MANAGED
ref class MyClass
#else
class MyClass
#endif
{
char pathName[128];
}

For managed compilation, a compiler error is given saying that mixed types
are not supported.

In C# unsafe code blocks, the fixed keyword is available for fixed size
buffers
public fixed char pathName[128];

What is the equivalent in C++/CLI?
Nov 17 '05 #1
2 4614
Something like this :-

ref class R
{
array<char>^ arr;
R()
{
arr = gcnew array<char>(128);
}
};

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"ldawson" <ld*****@newsgroup.nospam> wrote in message
news:eg**************@TK2MSFTNGP12.phx.gbl...
From the same C++ source code, I'm attempting to generate both an
unmanaged
DLL and a managed assembly. This will eliminate interop as the calling
code
is slowly migrated to .NET.
However, C++ native compilation allows fixed size buffers (e.g. char
pathName[128]) which we've used to represent a memory mapped file, and I
can't find out how to implement the same in C++/CLI
i.e.

#ifdef _MANAGED
ref class MyClass
#else
class MyClass
#endif
{
char pathName[128];
}

For managed compilation, a compiler error is given saying that mixed types
are not supported.

In C# unsafe code blocks, the fixed keyword is available for fixed size
buffers
public fixed char pathName[128];

What is the equivalent in C++/CLI?

Nov 17 '05 #2
ldawson wrote:
In C# unsafe code blocks, the fixed keyword is available for fixed size
buffers
public fixed char pathName[128];

What is the equivalent in C++/CLI?


Oddly, I just wrote a blog entry on this subject. You can check it out to
see inline_array in C++.

http://blogs.msdn.com/branbray/archi...20/441099.aspx

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
Bugs? Suggestions? Feedback? http://msdn.microsoft.com/productfeedback/
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: grunes | last post by:
I wish to fread a few thousand bytes at a time in turn from several very large files from a DVD data disk, under Redhat Fedora Linux. When this is done the DVD drive wastes a lot of time and...
11
by: Stephan Steiner | last post by:
Hi Generally, FileInfo fi = new FileInfo(path); long size = fi.Length; gets you the length of a file in bytes. However, when copying files, even while the copy operation is still in...
4
by: Paul | last post by:
I'm doing some Pinvoke stuff. How do I deal with functions that pass/receive structures that have fixed length char buffers? I see this: public struct MyArray // This code must appear in an...
4
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type...
4
by: taskswap | last post by:
I'm converting an application that relies heavily on a binary network protocol. Within this protocol are a lot of byte arrays of character data, like: public unsafe struct MsgAddEntry {...
1
by: O.B. | last post by:
In the example below, I'm trying to convert a fixed byte array to a string. I get an error about needing to use "fixed" but I have no clue where to apply it. Help? using System; using...
4
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this text data into a string. I've got it working just fine, but I have to put the text data into into a...
6
by: =?Utf-8?B?TFBldGVy?= | last post by:
Hi, I would copy the characters of a string variable to a fixed character buffer in a struct (and vice versa) in C#. public struct S { ... public fixed char cBuff; ...
6
by: =?Utf-8?B?TWFyZWs=?= | last post by:
Hi I am trying to dynamically create the following structure using AssemblyBuilder, TypeBuilder and DefineField: public struct SimpleType2 { public double dScalar1; public fixed double...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.