struct

Why have QString in struct sometimes a bad-ptr?

Hi there! I've got an complicated error. The software send PrintParamters to a Printer a couple of times. At a certain moment all QStrings of the Parameter Struct are broken (bad ptr) Is there an general issue with QStrings in Structs? here is the struct I'm using: typedef struct RecorderPrintParam { ES_DataType xxxxxxxxxx; bool ...

Default parameters of struct templates

I have a template struct tree_parse_info declared as follows: template < typename IteratorT, typename NodeFactoryT, typename T > struct tree_parse_info { // ... }; The compiler allows the follows code: tree_parse_info<> m_info; Why does this code compile even though we do not have default template parameters for the ...

Adding a field to a structure without breaking existing code

So I'm working with this huge repository of code and have realized that one of the structs lack an important field. I looked at the code (which uses the struct) as closely as I could and concluded that adding an extra field isn't going to break it. Any ideas on where I could've screwed up? Also: design advice is welcome - what's the be...

Sizeof struct in Go

I'm having a look at Go, which looks quite promising. I am trying to figure out how to get the size of a go struct, for example something like type Coord3d struct { X, Y, Z int64 } Of course I know that it's 24 bytes, but I'd like to know it programmatically.. Do you have any ideas how to do this ? ...

Size of structure

It is possible to get size of struct using Marshal.SizeOf(typeof(mystruct)); Is it possible to get size of a part of a structure(for example I pass to function the last field of a structure and it returns sum of sizes of previous fields)? As I understand is it possible using reflection? ...

COM pointer to struct

Hello, I'm using Visual Studio 2008/.NET 3.5. I used VS to make a COM component interoperable in .NET. I added a reference from the application to the COM DLL. The COM DLL is a 3rd party object - part of an SDK. For all methods and events everything is working just fine - COM objects/events are represented as a first class .NET objects...

Chaining properties in C# & unexpected results

I was just having a quick read through this article (specifically the bit about why he chose to use structs / fields instead of classes / properties) and saw this line: The result of a property is not a true l-value so we cannot do something like Vertex.Normal.dx = 0. The chaining of properties gives very unexpected results. What...

Swapping elements in an array of structs

Say I have this struct: struct MyStruct { int iID; int iMyNumber; }; Then I define an array of MyStructs: struct MyStruct msTest[3]; I'm doing a sorting operation on a struct similar to this one by looking at the ID. Now, as soon as I find out which records should be swapped to sort the array I have to do the actual swapping. I...

Can I designate a Java-like 'constructor' in c?

I want to 'construct' (read: malloc and memset) my hashtable in c. To do this, I created a function as follows: int maketable(struct hash_entry **table, int size){ table = (struct hash_entry **)malloc(size*sizeof(struct hash_entry *)); int i = 0; for (; i<size; i++) { memset(table[i], '\0', sizeof(struct hash_entry...

Destroying a struct object in C# ?

Hi All, I am a bit confused about the fact that in C# only the reference types get garbage collected. That means GC picks only the reference types for memory de-allocation. So what happens with the value types as they also occupy memory on stack ? ...

A C structure accessed in Java

I have a C structure that is sent over some intermediate networks and gets received over a serial link by a java code. The Java code gives me a byte array that I now want to repackage it as the original structure. Now if the receive code was in C, this was simple. Is there any simple way to repackage a byte[] in java to a C struct. I hav...

Is there a maximum limit to the size of a variable that should be allocated on a stack?

i declared a struct variable in C of size greater than 1024bytes. On running Coverity (a static code analyzer application) it reports that this stack variable is greater than 1024 bytes and therefore a cause of error. I'd like to know if I need to worry about this warning? Is there really a maximum limit to the size of a single stack var...

Is there a way to clone a class object in C#?

Possible Duplicate: Cloning objects in C# I have this class Object that has about 20 properties (they're all basic or struct types). Is there a simple way to create a clone of an instance of this object. A bit like the copy ctor in C++? This is for a Silverlight application. ...

access array from struct in C

In my data.h file I have: typedef struct { double ***grid; } Solver; In my .c file I have static Solver _solver; which first makes a call to a function to do some allocation on grid such as _solver.grid = malloc(....); //then makes a call to GS_init(_solver.grid); The GS_init function is declared in GS.h as: void GS_init(...

Initializing nested structures without defining all fields

I have a set of structs, defined as follows: typedef struct { int index; int array[10]; } Item; typedef struct { Item A; Item B; Item C; } Collection; And I want to declare a variable of type Collection as follows: Collection collection = { { 1, 0 }, /* item A */ { 2, 0 }, /* item B */ { 3, 0 } /*...

Overloading the "Set to equal to" operator.

I was reading a Business Primitives by CodeBetter.com and was toying around with the idea. Taking his example of Money, how would one implement this in a way that it can be used similarily as regular value types? What I mean by that is do this: Money myMoney = 100.00m; Instead of: Money myMoney = new Money(100.00m); I understand ...

very basic objective-c question

Hi all, I wrote a simple program to understand how objective-c works. This program is the i-ching, an ancient divination based on six lines response, calculated after launching three coins for six times, and then build an hexagram which is the reponse. I am stuck at this, that I am sure has simple solution. This is how I defined the li...

Why use function pointers in a struct in Objective-C?

Hey folks, I just read this http://stackoverflow.com/questions/2172887/use-c-struct-in-objective-c question, and I was wondering why anyone would want to use function pointers in structs. Wouldn't wrapping the functions in a class be equivalent? ...

C# Mapping struct in ActiveRecord

Hi here. i am making a little application to help me balance my checkbook. i am using Castle ActiveRecord to map the object properties to the database. now here is the problem. as i am making a money program i made a struct Currency The struct: public struct Currency { private long amount; private CurrencyType currencyType; ...

Overwriting Default values in C# structs

For an assignment I have to write a Tribool class in C# using a struct. There are only three possible tribools, True, False, and Unknown, and I have these declared as static readonly. Like this: public static readonly Tribool True, False, Unknown; I need my default constructor to provide a False Tribool, but I'm not sure how to go abo...