[Mono-list] Possible bug with casting struct pointers

Alan West alan@alanz.com
Sun, 27 Oct 2002 22:35:44 +0000


Hi, I've started working on bindings for DirectFB, and seem to have come 
across my first bug with mcs using the following code. I got my old Windows 
XP hard disk plugged in to try it out in VS.NET and all was fine... mcs I'm 
using was built from cvs about a week ago, I was gonna try the current cvs 
but it wont build now due to code in the Mono.Data.TdsClient area.

using System;

namespace testapp{
	public unsafe class LibTestAPI{

		struct LibTestStruct{
			void* pData;
			void* pTest1;
		}

		LibTestStruct* the_struct;

		public void Create(){
			IntPtr MyPtr = new IntPtr(0); // Usually created elsewhere
			the_struct = (LibTestStruct*) MyPtr.ToPointer();  // error CS1002
		}
	}

	class TestApp{
		[STAThread]
		static void Main(string[] args){
			LibTestAPI myapi = new LibTestAPI();
			myapi.Create();
		}
	}
}

# mcs --unsafe testapp.cs
syntax error, expecting BASE BOOL BYTE CHAR CHECKED DECIMAL DOUBLE FALSE FLOAT 
INT LONG NEW NULL OBJECT SBYTE SHORT SIZEOF STRING THIS TRUE TYPEOF UINT 
ULONG UNCHECKED USHORT VOID OPEN_PARENS TILDE PLUS MINUS BANG BITWISE_AND 
STAR OP_INC OP_DEC LITERAL_INTEGER LITERAL_FLOAT LITERAL_DOUBLE 
LITERAL_DECIMAL LITERAL_CHARACTER LITERAL_STRING IDENTIFIER
testapp.cs(15) error CS1002: Expecting `;'
Compilation failed: 1 error(s), 0 warnings