473,382 Members | 1,365 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,382 software developers and data experts.

Pointer problems


Here is the relevant part of my structure...

[StructLayout(LayoutKind.Sequential)]
public unsafe struct PPF_FILTER_DESCRIPTOR
{
public int* SrcAddr;
public int* SrcMask;
public int* DstAddr;
public int* DstMask;

}

private PPF_FILTER_DESCRIPTOR filter;
I'm trying to fill the field, SrcAddr -
an int* PPF_FILTER_DESCRIPTOR.SrcAddr
as filter.SrcAddr

I can't seem to do this w/o errors...
Obviously, this is a hobby project.

Here's what I've been trying

IPAddress sip = IPAddress.Parse("10.1.1.1");
Unsafe {
src = BitConverter.ToInt32(sip.GetAddressBytes(), 0);
filter.SrcAddr = &src;
}

This errors w/: You can only take the address of an unfixed expression
inside of a fixed statement initializer
I've tried:
fixed(filter.SrcAddr = &src;)

This errors w/: Type or namespace name expected, but fieldname found.

Not sure what to try next. Any suggestions?

Thanks
Dec 2 '07 #1
2 1105
>Not sure what to try next. Any suggestions?

fixed (int* p = &src)
{
filter.SrcAddr = p;
// ...
}
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 2 '07 #2
On Sun, 02 Dec 2007 20:04:16 +0100, Mattias Sjögren
<ma********************@mvps.orgwrote:
>>Not sure what to try next. Any suggestions?

fixed (int* p = &src)
{
filter.SrcAddr = p;
// ...
}
Mattias
Doh...

Thank you...
Dec 2 '07 #3

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

Similar topics

2
by: Thomas Baier | last post by:
Hi there, I've got a class with an array of pointers to objects of the same class. I thought of doing it like that: class test { test **array_var; ... }; void method::test(test object) {
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
26
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I...
2
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres...
4
by: palani12kumar | last post by:
Can any one tell me what is generic poiner? im struggling a lot to know what it is?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.