Hi,
I have a short C program that writes into a file until there is no more space on disk:
#include <stdio.h>
int main(void) {
char c[] = "abcdefghij";
size_t rez;
FILE *f = fopen("filldisk.dat", "wb");
while (1) {
rez = fwrite(c, 1, sizeof(c), f);
if (!rez) break;
}
fclose(f);
return 0;
}
When I run the progra...
I want to model a purification of the Petri Network. And i was given the suggestion to use a matrix which is allocated dynamically. After thinking about the problem i came up with a different approach like so:
A static matrix of n transitions and p locations and a function which returns the purified matrix from the static matrix.
Which...
Hi,
Has anybody added a pass to gcc ? or not really a pass but adding an option to do some nasty things... :-) ...
I still have the same problem about calling a function just before returning from another...so I would like to investigate it by implementing something in gcc...
Cheers.
EDIT: Adding a pass to a compiler means revisiting...
I'm getting the infamous 0xC00000FD (stack overflow) exception from my application when I call into a native DLL. This is being done from a managed C# application on Windows CE 5 (SH4 processor). Compiling the same DLL for Windows XP using the same managed application and everything works fine (no overflow). The routine in the DLL is ...
From what I understand, #define x y and const int x = y; should work identically under the Visual Studio compiler, but const int x = y; is the preferred method.
The C code I have looks something like this:
static const int x = 100000;
void SomeFunction(...)
{
volatile static int y = x;
...
}
The problem here is with the decl...
I'm writing a program where performance is quite important, but not critical. Currently I am reading in text from a FILE* line by line and I use fgets to obtain each line. After using some performance tools, I've found that 20% to 30% of the time my application is running, it is inside fgets.
Are there faster ways to get a line of text?...
Updated: The actual resolution that the compile box which served my compile request was different. In the slower instance I was running code compiled on a SuSE 9 but running on a SuSE 10 box. That was sufficient difference for me to drop it and compare apples to apples. When using the same compile box the results were as follows:
g++...
I want to know the first double from 0d upwards that deviates by the long of the "same value" by some delta, say 1e-8. I'm failing here though. I'm trying to do this in C although I usually use managed languages, just in case. Please help.
#include <stdio.h>
#include <limits.h>
#define DELTA 1e-8
int main() {
double d = 0; // c...
I want to make my own malloc/free so I can make a precise copying allocator.
Any gurus have any tips and suggestions?
I have a few questions for now:
Should I just malloc large chunks of memory, and then distribute from that so I don't have to call the system calls?
How are copying collectors usually done? I would imagine that this p...
Using C winapi, how can you capture receieved data from a commport that is open exclusively by another program.
I know there are programs that do this, but I want to code my own monitoring software for a specific purpose and was wondering how is it done?
...
I have this program that I want other processes to be able to call functions on (through unix sockets). The message protocol is very simple, the function name, a function signature, and a buffer (char *) that holds the parameters.
When a module in my program wants to allow a function to be accessible, it registers the name and signature...
I've been playing around with LLVM hoping to learn how to use it.
However, my mind is boggled by the level of complexity of the interface.
Take for example their Fibonacci function
int fib(int x) {
if(x<=2)
return 1;
return fib(x-1) + fib(x-2);
}
To get this to output LLVM IR, it takes 61 lines of code!!!
They a...
I'm compiling newlib for a bespoke PowerPC platform with no OS. Reading information on the net I realise I need to implement stub functions in a <newplatform> subdirectory of libgloss.
My confusion is to how this is going to be picked up when I compile newlib. Is it the last part of the --target argument to configure e.g. powerpc-ibm-<n...
I am planning to write a code library to access some hardware at a low-level (i.e. flipping register bits and such).
Previously, I wrote everything as C functions and used extern "C" to make the library compile for both C and C++ code. So, both C and C++ users merely had to include the header file and call the functions as they were.
...
The domain of interest is string matching. Assume I have a structure like this.
typedef struct
{
char *name,
int (*function)();
} StringArray
StringArray s[] =
{
{"George", func1},
{"Paul", func2},
{"Ringo", func3},
{"John", func4}
}
There are a fixed number of strings in the array. They are hard cod...
Occasionally I need to use fixed-width integers for communication with external devices like PLCs. I also use them to define bitmasks and perform bit manipulation of image data. AFAIK the C99 standard defines fixed-width integers like int16_t. However the compiler I use, VC++ 2008 doesn't support C99 and AFAIK Microsoft is not planning t...
The experiment I am currently working uses a software base with a complicated source history and no well defined license. It would be a considerable amount of work to rationalize things and release under a fixed license.
It is also intended to run a a random unixish platform, and only some of the libc's we support have GNU getline, but ...
One of my projects on Linux uses blocking sockets. Things happen very serially so non-blocking would just make things more complicated. Anyway, I am finding that often a recv call is returning -1 with errno set to EAGAIN.
The man page only really mentions this happening for non-blocking sockets, which makes sense. With non-blocking, the...
I'm trying to make a simple textured rectangular in OpenGL using SOIL and GLUT.
This is my Display function (executed in main by glutDisplayFunc(Display)):
void Display ()
{
GLuint tex_2d;
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glClear (GL_COLOR_BUFFER_BIT);
glClearColor (1.0,1.0,1.0,1.0);
gluLookAt (e...
In an application I maintain, we've encountered a problem with file descriptor limitations affecting the stdlib. This problem only affects the 32-bit version of the standard lib.
I have devised a fix for my code and would like to implement it, but only when compiling for 32-bit executable. What pre-processor symbol can I #ifdef for to d...