struct

Passing objects between C# and C

Hi, My application consist of C# code with unmanaged C dll calls. In my C# code I have an object/class where its properties are both system types such as string and int and other objects I have defined. I would like to pass this complex (Graph.cs) object to my C (dll) code, what implementation would you suggest here? I have tried movin...

C-structs, NSObjects, float, int, double, ...

Hello, First of all: this is a though question, sorry for that, but I hope someone can help me! I'm making a UIML renderer on the iPhone. UIML is a language to describe interfaces. I want to render the XML and show the Interface on the iPhone. To inform you bettter, i first explain what I'm doing: <?xml version="1.0"?> <uiml> <in...

Find maximum signed short integer in python

How do I get the maximum signed short integer in Python (i.e. SHRT_MAX in C's limits.h)? I want to normalize samples from a single channel of a *.wav file, so instead of a bunch of 16-bit signed integers, I want a bunch of floats between 1 and -1. Here's what I've got (the pertinent code is in the normalized_samples() function): def s...

Initialize unmanage struct from managed code (C#)

I have a structure in C++ that I want to reflect in C# code (goover all field and initiate with specific order) that I want to dump the structure memeory as binary data into a file. I have a problem in array decleration in the sturct if I declare int dummy_4[10] the compiler raise error that can't mix managed & unmanaged types. if I dela...

Design Question: How can I maintain a stack of object

I have a struct call 'A', which has an attribute 'i', like this: typedef struct a { a() { i = 0;} int i; } A; And I would like to maintain a stack of A in my Main class: class Main { public: void save(); void doSomethingToModifyCurrentA(); void restore(); private: A currentA; stack<A> aStack...

[C++] Deque of user-defined structures

I've got a user-defined structure struct theName and I want to make a deque of these structures (deque<theName> theVar). However when I try to compile I get this error: In file included from main.cpp:2: Logger.h:31: error: ISO C++ forbids declaration of ‘deque’ with no type Logger.h:31: error: expected ‘;’ before ‘<’ token Why can't I...

Can I extract struct or public class members using a template?

Basically, I have lots of differently typed structs like this: typedef struct { char memberA; int memberB; ... } tStructA; Is it possible to use a template to get/extract an arbitrary member from the struct? In pseudocode, I'm looking for something like this: /*This is pseudocode!*/ template <typename STRUCT_TYPE, typenam...

What are the C# equivalent of these C++ structs

typedef union _Value { signed char c; unsigned char b; signed short s; unsigned short w; signed long l; unsigned long u; float f; double *d; char *p; } Value; typedef struct _Field { WORD nFieldId; BYTE bValueType; Value Value; } Field; typedef s...

C# and VS.NET : Cannot assign property of struct returned from method

I got the following error which I translated from german: error BC30068: The Expression is a value and cannot be target of an assignment. Iam trying to do the following: sheet.Cells(row, col).Value = newVal ' this is VB Where I have declared Cells as: public Cell Cells(int x, int y) // this is C# { return new Cell(this, x, y); ...

Convert struct to query Coldfusion

Wondering if anyone can assist I am utilizing some code from RIAForge which integrates with the Last.fm api... One of the methods outputs as a struct, but I would like to modify the code so it outputs as an array, am unsure of how to do this.. Currently the code is like this <cfscript> var args = StructNew(); var returnStruct = Str...

Are C# structs thread safe?

Is a C# struct thread-safe? For example if there is a: struct Data { int _number; public int Number { get { return _number; } set { _number = value; } } public Data(int number) { _number = number; } } in another type: class DadData { public Data TheData { get; set; } } is property named TheData, thread-safe? ...

Can I create accessors on structs to automatically convert to/from other datatypes?

is it possible to do something like the following: struct test { this { get { /*do something*/ } set { /*do something*/ } } } so that if somebody tried to do this, test tt = new test(); string asd = tt; // intercept this and then return something else ...

typedef struct problem

hi, I'm new in c++, how to made code below work (compile without a syntax error)? typedef struct _PersonA{ char name[128]; LPPersonB rel; }PersonA, *LPPersonA; typedef struct _PersonB{ char name[128]; LPPersonA rel; }PersonB, *LPPersonB; Please, don't ask me why I need to do it like this, because it is just an exampl...

Why often a struct's tagName differs from the typedef's name?

Sometimes I see code like this (I hope I remember it correctly): typedef struct st { int a; char b; } *stp; While the usual pattern that I familiar with, is: typedef struct st { int a; char b; } st; So what's the advantage in the first code example? ...

How to pass an array of struct using pointer in c/c++ ?

Hi, in C code I'm stuck to pass an array of struct to a function, here's the code that resembles my problem: typedef struct { int x; int y; char *str1; char *str2; }Struct1; void processFromStruct1(Struct1 *content[]); int main() { Struct1 mydata[]= { {1,1,"black","cat"}, {4,5,"red","bird"}, {6,7,"brown...

Pushing a 1-D array onto a 2-D array in C

I am working on a queue data structure. The structure is: struct queue { char array[MAX_LENGTH][8]; int back; }; It is designed to store a list of MAX_LENGTH strings that are 7 chars long. I wish to push a 1D array of 8 chars (well, 7 chars and \0, just like the array in the struct). I have this push code: void push (struct queue ...

How to compare two structs in c ?

Hi! I know, that if i want to compare two structs than i have to write it for myself, because there isn't any function for this, but i can't figure out how should i do that. I have three structs : primary, secondarystruct, and difference(this should contain the different items). All three has the following members : char * filename, cha...

C# Struct No Parameterless Constructor? See what I need to accomplish

I am using a struct to pass to an unmanaged DLL as so - [StructLayout(LayoutKind.Sequential)] public struct valTable { public byte type; public byte map; public byte spare1; public byte spare2; public int par; public int min; public byte[...

Storing vector in a struct C++

Why can't I do this: struct sName { vector<int> x; }; It takes only three pointers to store a vector, so I should be able to do this? ...

C#. Where struct methods code kept in memory?

It is somewhat known where .NET keeps value types in memory (mostly in stack but could be in heap in certain circumstances etc)... My question is - where is the code of the struct? If I have say 16 byte of data fields in the struct and a massive computation method in it - I am presuming that 16 byte will be copied in stack and the met...