struct

Does Objective-C 2.0 garbage collection collect C structures?

What exactly does the Objective-C garbage collector collect? For example, if I'm writing a program in Objective-C 2.0, and I use some plain C structs, does my code need to worry about manually freeing that memory? ...

ColdFusion static key/value list?

I have a database table that is a dictionary of defined terms -- key, value. I want to load the dictionary in the application scope from the database, and keep it there for performance (it doesn't change). I gather this is probably some sort of "struct," but I'm extremely new to ColdFusion (helping out another team). Then, I'd like to ...

Hiding members in a C struct

I've been reading about OOP in C but I never liked how you can't have private data members like you can in C++. But then it came to my mind that you could create 2 structures. One is defined in the header file and the other is defined in the source file. // ========================================= // in somestruct.h typedef struct { ...

Swig - wrapping C struct

Hello everyone, I am trying to write Python wrap for C code which uses struct. modules.c: struct foo { int a; }; struct foo bar; modulues.i %module nepal %{ struct foo { int a; } %} extern struct foo bar; But during compiling I am given error: In function ‘Swig_var_bar_set’: error: ‘bar’ undeclared (fi...

Casting to global variable from LPVOID - C

I am trying to cast data to a struct from a parameter passed into my method, I need the data to be passed to a global variable as it is needed elsewhere in my application. I have tried the following but I get errors saying that diceResult is an undeclared identifier Here is the code itself: //Structure to hold dice data typedef struct...

Assigning values to chars in structs - c

I have been having trouble getting my head around allowing a user to enter words into structs. The struct I am using is below struct class { char class_num[4]; char *class_name; } If anyone could point me how to do this or at least point me in the right direction that wuld be great. thanks ...

Core-audio - constructing an AudioBufferList struct (Q about c struct definition)

The definition of AudioBufferList looks weird to me… i guess my C is not so good struct AudioBufferList { UInt32 mNumberBuffers; AudioBuffer mBuffers[kVariableLengthArray]; }; typedef struct AudioBufferList AudioBufferList; Why AudioBuffer mBuffers[kVariableLengthArray]; and not AudioBuffer *mBuffers; ? kVariable...

How to make a struct maker like CGRectMake (iphone)

i have a struct HLRange with two CGFloat's struct HOLRange { CGFloat min; CGFloat max; }; typedef struct HOLRange HOLRange; but how do i make a function like HLRangeMake(1,2); .. like CGRectMake? --EDIT-- my header file #import <Foundation/Foundation.h> struct HOLRange { CGFloat min; CGFloat max; }; typedef struct HOLRange...

assignment from incompatible pointer type

I have set up the following struct: typedef struct _thread_node_t { pthread_t thread; struct thread_node_t *next; } thread_node_t; ... and then I have defined: // create thread to for incoming connection thread_node_t *thread_node = (thread_node_t*) malloc(sizeof(thread_node_t)); pthread_create(&(thread_node->thread), NULL, c...

How can I modify the value of a string defined in a struct?

Hi, Based on your comments, let me modified the original question... I want to create a struct with size of 4kb (this size is a requirement so I have to meet it). The problem was that I couldn't modify the value of the string variable contained in the struct because the compiler throws a segmentation fault. Currently, if I use a pointe...

Mapping C structure to an XML element

Suppose I have a structure in C or C++, such as: struct ConfigurableElement { int ID; char* strName; long prop1; long prop2; ... }; I would like to load/save it to/from the following XML element: <ConfigurableElement ID="1" strName="namedElem" prop1="2" prop2="3" ... /> Such a mapping can be trivially done in Java/C...

How to check if the internal typedef struct of a typedef struct is NULL ?

typedef struct { uint32 item1; uint32 item2; uint32 item3; uint32 item4; <some_other_typedef struct> *table; } Inner_t; typedef struct { Inner_t tableA; Inner_t tableB; } Outer_t; Outer_t outer_instance = { {NULL}, { 0, 1, 2, 3, table_defined_somewhere_else, } }; My question i...

C/C++: Passing a structure by value, with another structure as one of its members, changes values of this member's members.

Sorry for the confusing title, but it basically says it all. Here's the structures I'm using (found in OpenCV) : struct CV_EXPORTS CvRTParams : public CvDTreeParams { bool calc_var_importance; int nactive_vars; CvTermCriteria term_crit; CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ), ca...

What makes this struct incomplete?

gcc lovingly throws me this error: bst.c:33: error: invalid application of ‘sizeof’ to incomplete type ‘struct BSTNode’ What makes BSTnode incomplete? Below are the struct definitions relevant to BSTnode. struct BSTnode{ struct BSTnode * left; struct BSTnode * right; struct hash minhash; struct hash maxhash; st...

Php 2d array as C# 2d array/struct

I'm using MailChimp's API to subscribe email to a list. Function listsubscribe() is used for email subscription: public static listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome) I downloaded ...

Returning a struct pointer

Suppose I have the following struct and function returning a pointer: typedef struct { int num; void *nums; int size; } Mystruct; Mystruct *mystruct(int num, int size) { //Is the following correct? Is there a more efficient way? Mystruct mystruct; mystruct.num = num; mystruct.size = size; mystruct.nums = malloc(nu...

Overlaying several CLR reference fields with each other in explicit struct?

Edit: I'm well aware of that this works very well with value types, my specific question is about using this for reference types. Edit2: I'm also aware that you can't overlay reference types and value types in a struct, this is just for the case of overlaying several reference type fields with each other. I've been tinkering around wit...

Is there a practical alternative to struct inheritance? (C#)

I am writing code that will populate the Margin, Padding and BorderThickness properties of classes in the System.Windows.Documents namespace. Each of these properties accepts a value in the form of a System.Windows.Thickness, which is a struct. However, I wish to associate some additional data with each of these property assignments, wh...

iPhone/Objective-C struct question my own CGRectZero

I am designing a Padding struct as follows: /* Padding. */ struct CGPadding { CGFloat left; CGFloat top; CGFloat right; CGFloat bottom; }; typedef struct CGPadding CGPadding; CG_INLINE CGPadding CGPaddingMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) { CGPadding p; p.left = left; p.top = top; p.right = right; p.bott...

How to determine if a .NET Type is a custom struct?

Hi! How to write a simple method, that checks whether a concrete type is a custom struct (created with public struct { };) or not. Checking Type.IsValueType is not enough, because it is also true to int, long, etc, and adding a check to !IsPrimitiveType won't exclude decimal, DateTime and maybe some other value types. I know that most ...