I need the fastest way to periodically sync file with memory.
What I think I would like is to have an mmap'd file, which is only sync'd to disk manually. I'm not sure how to prevent any automatic syncing from happening.
The file cannot be modified except at the times I manually specify. The point is to have a checkpoint file which kee...
Hello,
i use gconf/gconf-client.h in ,y C application, but i don't know, is gconf on users machine. How can i check gconf/gconf-client.h and gconf there or not?
Thank you
...
I was recently building a certain shared library (ELF) targeting x86-64 architecture, like this:
g++ -o binary.so -shared --no-undefined ... -lfoo -lbar
This failed with the following error:
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
Of course, it means I nee...
How to find the library, which contains the definition of particular function? I am getting linker error.
...
I currently have inline functions calling another inline function (a simple 4 lines big getAbs() function). However, I discovered by looking to the assembler code that the "big" inline functions are well inlined, but the compiler use a bl jump to call the getAbs() function.
Is it not possible to inline a function in another inline funct...
I'm trying to call a c function from my extension and have narrowed the problem down to this test case.
#import "Python.h"
...
// Called from python with test_method(0, 0, 'TEST')
static PyObject*
test_method(PyObject *args)
{
int ok, x, y, size;
const char *s;
// this causes Segmentation fault
//ok = PyArg_ParseTupl...
I am new to C and I am very much confused with the C strings. Following are my questions.
Finding last character from a string
How can I find out the last character from a string? I came with something like,
char *str = "hello";
printf("%c", str[strlen(str) - 1]);
return 0;
Is this the way to go? I somehow think that, this is not th...
#include<stdio.h>
#include<conio.h>
void inversion(void);
void ways(void);
void prime(void);
void power(void);
void fibonacci(void);
void main(void)
{
char choice;
printf("Enter a choice:\n 1.Perform inversion of digits \n 2.calculate all the ways that a positive number can be get by adding \n 3.Calculate prime numbers in a range\n 4.Cal...
I'm trying to compile the same C file on two different machines with different versions of cc.
gcc version 3.2.3 says warning: 'foo' was declared implicitly 'extern' and later 'static'
gcc version 4.1.2 says error: static declaration of 'foo' follows non-static declaration
AFAICT, both have the same CFLAGS. I'd like to make gcc 4.1.2 ...
[edit] For background reading, and to be clear, this is what I am talking about: Introduction to the volatile keyword
When reviewing embedded systems code, one of the most common errors I see is the omission of volatile for thread/interrupt shared data. However my question is whether it is 'safe' not to use volatile when a variable is ...
I have this typedef:
typedef union
{
unsigned Value;
unsigned Timestamp:16;
} BITFIELD;
and get this compiler warning:
BITFIELD bitfield;
// read from uninitialised memory - may result in unexpected behaviour
bitfield.Timestamp = 12;
Now, the warning disappears when I use a short instead of the bitfield:
typedef union
{
...
Hi,
I was told by my boss to write unit tests for the little c file (foo.c) I wrote. I read a lot about the background of unit testing online, like testing only one function and making tests fully automated, but I did not find any tutorial about how to implement an actual unit test. I tried the following approach, but failed.
/*f...
I would like to add Unicode support to a C library I am maintaining. Currently it expects all strings to be passed in utf8 encoded. Based on feedback it seems windows usually provides 3 function versions.
fooA() ANSI encoded strings
fooW() Unicode encoded strings
foo() string encoding depends on the UNICODE define
Is there an easy w...
My funciton takes a number input from the user and recursively sums the number 'n' to one.
Inputting a 5 would sum 1/5 + 1/4 + 1/3+ 1/2 + 1/1.
#include<stdio.h>
#include<conio.h>
//to
float recursion(float num,float sum);
void main(void)
{
float num=5,sum=0;
//input num
printf("%d",recursion(num,sum));
getch();
}
float recurs...
I have some applications that are written in ANSI C. Will I be able to run the binary files of those apps on the iPhone? If not directly, is there any other useful method to do so? I don't want to rewrite the applications.
...
i have been following this course in youtube and it was talking about how some programmers can use there knowledge of how memory is laid to do clever things..
one of the examples in the lecture was something like that
#include <stdio.h>
void makeArray();
void printArray();
int main(){
makeArray();
printArray();
r...
Hi,
I have a new project assigned to me today. I need to load a TTF file and then write the specified string to a bitmap using that font. However, I do not have much information about the TTF structure. Is there any library specifically for this job?
...
Possible Duplicates:
C/C++: Detecting superfluous #includes?
How should I detect unnecessary #include files in a large C++ project?
I'm looking to do some house cleaning in our code base. I would like to start by removing all unnecessary header includes from our source files (*.c and *.cpp). Does anyone know of a tool or te...
which of these two is better?
void SetBit(int *flag, int bit)
{
*flag |= 1 << bit;
}
Or
int SetBit(int flag, int bit)
{
flag |= 1 << bit;
return flag;
}
...
Hey guys, I'm trying to compute the cumulative distribution function of the standard normal distribution for a formula in C using the GSL (Gnu Statistics Library)
I've installed and included gsl but am having trouble understanding how to use it.
I think the function I need is:
double gsl_ran_lognormal (const gsl_rng * r, double zeta, ...