I have some code that uses some shared libraries (c code on gcc). When compiling I have to explicitly define the include and library directories using -I and -L, since they aren't in the standard places. When I try to run the code, I get the following error:
./sync_test
./sync_test: error while loading shared libraries: libsync.so: can...
I am trying to compile the Python bindings for OpenSSL (pyOpenSSL) on Windows Vista x64 using Visual Studio 2008. When I run python setup.py build_ext -I C:\OpenSSL\include, it dies with the following error:
building 'OpenSSL.crypto' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3...
I have approximately 30 variadic functions. Each one accepts a path as the final argument, i.e.:
bool do_foo(struct *f, int q, const char *fmt, ...)
In each function, I have to check that the expanded format is less then or equal to a certain size. So, I find myself copy / pasting the same chunk of code to check for how many characters...
Hi Everyone,
I am running some code that I have written in C which calls the md5 hashing functionality from a hashing library that someone else wrote (md5.c & md5.h). The odd behavior I have been seeing is:
hashing working perfectly = I hash a string, and it comes out to the exact hash that I have verified it to be with multiple other...
Copying directory from source tree to binary tree. For example: How to copy www to bin folder.
work
├─bin
└─src
├─doing
│ └─www
├─include
└─lib
Thanks.
...
Is there any difference in these two? If so, what exactly is the difference? Assume they are in a C function that may be called multiple times.
declare and assign in same statement
static uint32_t value = x; // x varies and may be passed into function.
declare in one statement and assign in next statment.
static uint32_t value;
v...
I've always used typedef in embedded programming to avoid common mistakes:
int8_t - 8 bit signed integer
int16_t - 16 bit signed integer
int32_t - 32 bit signed integer
uint8_t - 8 bit unsigned integer
uint16_t - 16 bit unsigned integer
uint32_t - 32 bit unsigned integer
The recent embedded muse (issue 177, not on the website yet) intr...
Can gcc spit out, given a C file, a list of the all function calls that occur, with filename and line number both for the call itself and for the function's declaration?
I know gcc somehow retains this information with -g (debuggers rely on it) and that it can dump control flow graphs with -dr (but without filenames or line numbers); bu...
I need C code to return the number of 1's in an unsigned char in C. I need an explanation as to why it works if it's not obvious. I've found a lot of code for a 32-bit number but not much for an unsigned char.
...
void max_min(sqlite3 *db)
{
//call back*********
int i, ncols;
sqlite3_stmt *stmt;
char *sql;
const char *tail;
char *zErrMsg = 0;
int rc;
//******************
//min/max variables
char min[20];
char max[20];
//we want only the min and max value of this table
sql = "SELECT MIN(Start...
My understand has always been that when I declare an array on the stack with a size that comes in as a variable or parameter, I should get an error.
However, I noticed that I do not get any error if I do not explicitly initialize the array (yes, it won't be on the stack, but I'm wondering about the lack of error).
For example, the foll...
Is there an easy way to reference a column in a 2-D array as a separate 1-D array in plain old C (not C++ or C#)? It's easy to do this for a row. Asssume I have 2 functions:
double doSomethingWithARow( double theRow[3] );
double doSomethingWithACol( double theCol[100] );
Then, I might use the first one like this:
double matrix[100][3...
I want to invalidate the window when it's created. How can I do that? calling InvalidateRect during WM_CREATE doesn't work.
The thing is I call SetWindowLongPtr in WM_CREATE and set GWLP_USERDATA. WM_PAINT looks for some pointer in USER_DATA but the first time I receive WM_PAINT the data isn't apparently still there so it doenst paint m...
The program is supposed to calculate the number of arguments, iterate over the list of arguments, for each argument convert the argument to an integer and copy it to an array, iterate over the elements of the array, adding the value of each one to a variable (this computes the sum of elements), and print the sum. There will not be more t...
I have seen and used C++ code like the following:
int myFourcc = 'ABCD';
It works in recent versions of GCC, not sure how recent.
Is this feature in the standard?
What is it called?
I have had trouble searching the web for it...
EDIT:
I found this info as well, for future observers:
from gcc documentation
The compiler values a...
Still learning C and I was wondering:
Given a number, is it possible to do something like the following?
char a = 5;
printf("binary representation of a = %b",a);
> 101
Or would i have to write my own method to do the transformation to binary?
...
I have legacy C code base at work and I find a lot of function implementations in the style below.
char *DoStuff(char *inPtr, char *outPtr, char *error, long *amount)
{
*error = 0;
*amount = 0;
// Read bytes from inPtr and decode them as a long storing in amount
// before returning as a formatted string in outPtr.
...
Hello,
I have a structure that has an array of pointers. I would like to insert into the array digits in string format, i.e. "1", "2", etc..
However, is there any difference in using either sprintf or strncpy?
Any big mistakes with my code? I know I have to call free, I will do that in another part of my code.
Many thanks for any adv...
How can i do subtraction of integers in C without using either the unary or binary '-' operator?
Or can we do the same for other data types like float/double?
...
I am going to use GLib's Hash table implementation in a C program and just for now
I am just experimenting with it. I wrote the following piece of code for testing:
#include <glib.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int main(){
// Some codes and declerations here
GHashTable *g_hash...