c

Footprint of Lua on a PPC Micro

We're developing some code on Freescale PPC micros (5517 and 5668 at the moment), and I was wondering if we could put Lua on them. The devices need to be easily programmed/reconfigured in the field, and the current product uses a proprietary interpreted logic language that can be loaded in, and our software (written in C) runs an interp...

how to start writing a very simple programming language

Recently, I was going around looking for ideas on what I can build using C this summer and I came across this post: http://stackoverflow.com/questions/1257376/interesting-project-to-learn-c Implement a programming language. This doesn't have to be terribly hard - I did the language that must not be named - but it will force you...

C onefile program printing (on stdout) self complete source code.

Hello, I hear 3 years ago problem and apparently have infinity solutions. I want to find one of this infinity set. Problem: Write program (have only one file example "selfsource.c") who printing on stdout self source code and exits. All techniques all alowed. Anyone can help me? ...

Reverse P/Invoke tutorial ?

I've a old C/C++ class that i want to refactor and access from .net using PInvoke All P/Invoke tutorials refers to call win32 api but i haven't found anything to code the other side Any tips/ideas ? my c/c++ experience is pretty rusty :( UPDATE - this is for wrapping existing C/C++ code so it can called from .net using P/Invoke How d...

Gradient algorithm produces little white dots

I'm working on an algorithm to generate point to point linear gradients. I have a rough proof of concept implementation done: GLuint OGLENGINEFUNCTIONS::CreateGradient( std::vector<ARGBCOLORF> &input,POINTFLOAT start, POINTFLOAT end, int width, int height,bool radial ) { std::vector<POINT> pol; std::vector<GLubyte> pdata(width *...

c vs c++ on solaris 9 platform question

Hi, I have a program that I am sharing with a third party. I will be providing a bin executable to them. It is written in c++ but uses some c as well. they are suggesting that it needs to be c only. Do you guys think this will be a problem since I will be compiling and building it on a sparc station that will somewhat match their syste...

how to view printf output in win32 app on visual studio 2010?

How can you view printf output in a win32 application (entering with a WinMain) on visual studio 2010? ...

openssl api verify the public key matches private key

How do I write an openssl server that on a single port has two different active RSA private keys? The openssl documentation seems to implies there can only be one rsa private key active at time with in a context. So I was thinking I have two active context, but what is the code to handle figuring out which connection matches which contex...

[ebp + 6] instead of +8 in a JIT compiler

I'm implementing a simplistic JIT compiler in a VM I'm writing for fun (mostly to learn more about language design) and I'm getting some weird behavior, maybe someone can tell me why. First I define a JIT "prototype" both for C and C++: #ifdef __cplusplus typedef void* (*_JIT_METHOD) (...); #else typedef (*_JIT_METHOD) (); #en...

Clamping a vector to a minimum and maximum?

I came accross this: t = Clamp(t/d, 0, 1) but I'm not sure how to perform this operation on a vector. What are the steps to clamp a vector if one was writing their own vector implementation? Thanks clamp clamping a vector to a minimum and a maximum ex: pc = # the point you are coloring now p0 = # start point p1 = # end point v...

Passing integers as constant references versus copying

This might be a stupid question, but I notice that in a good number of APIs, a lot of method signatures that take integer parameters that aren't intended to be modified look like: void method(int x); rather than: void method(const int &x); To me, it looks like both of these would function exactly the same. (EDIT: apparently not in so...

How efficient is an if statement compared to a test that doesn't use an if? (C++)

I need a program to get the smaller of two numbers, and I'm wondering if using a standard "if x is less than y" int a, b, low; if (a < b) low = a; else low = b; is more or less efficient than this: int a, b, low; low = b + ((a - b) & ((a - b) >> 31)); (or the variation of putting int delta = a - b at the top and rerplacing instance...

Algorithm to generate radial gradient

I have this algorithm here: pc = # the point you are coloring now p0 = # start point p1 = # end point v = p1 - p0 d = Length(v) v = Normalize(v) # or Scale(v, 1/d) v0 = pc - p0 t = Dot(v0, v) t = Clamp(t/d, 0, 1) color = (start_color * t) + (end_color * (1 - t)) to generate point to point linear gradients. It works very well for me...

libcurl (c api) READFUNCTION for http PUT blocking forever

I am using libcurl for a RESTful library. I am having two problems with a PUT message, I am just trying to send a small content like "hello" via put. My READFUNCTION for PUT's blocks for a very large amount of time (minutes) when I follow the manual at curl.haxx.se and return a 0 indicating I have finished the content. (on os X) Wh...

Posix equivalent of LocalAlloc(LMEM_ZEROINIT, size)

I have code which works on windows, that calls LocalAlloc as follows: LocalAlloc(LMEM_ZEROINIT, size) I need the equivalent malloc or calloc call to get this to work on Unix systems, through Mono. Simple answer? ...

Should I use C(99) booleans ? ( also c++ booleans in c++ ?)

I haven't done much c programming but when I do when I need a false I put 0 when I want true I put 1, (ex. while(1)), in other cases I use things like "while(ptr)" or "if(x)". Should I try using C99 booleans, should I recommend them to others if I'm helping people new to programming learn c basics(thinking of cs 1?? students)? I'm p...

shared global variables in C

How can I create global variables that are shared in C? If I put it in a header file, then the linker complains that the variables are already defined. Is the only way to declare the variable in one of my C files and to manually put in externs at the top of all the other C files that want to use it? That sounds not ideal. ...

need to get computer speaking to a cell phone

i have this super manual: http://www.arib.or.jp/IMT-2000/V710Dec08/5_Appendix/R99/27/27005-320.pdf i dont understand whether it is for every phone or just a certain subset i would like to know what i need to get started to have my computer speak to the phone i am ready to write in c#, c++, or what ever they need has anyone had exper...

Need help for this syntax: "#define LEDs (char *) 0x0003010"

I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code. #define Switches (volatile char *) 0x0003000 #define LEDs (char *) 0x0003010 void main() { while (1) *LEDs = *...

Antialiasing algorithm?

I have textures that i'm creating and would like to antialias them. I have access to each pixel's color, given this how could I antialias the entire texture? Thanks ...