c

Convert files of any types to a file with c strings.

Please suggest a small command-line utility (for Windows) to convert files from particular directory to a valid c file. Maybe it can be done just with batch commands? The resulting file should look like this: static const unsigned char some_file[] = { /* some_file.html */ 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x7...

How could I create a static library using visual stdio tools on the command line and automate .def creation

I'd like to create a static library using windows tools (cl.exe, link.exe, lib.exe, etc.) but I don't want to manually enter the names of the functions to export either in a .def file or specifying __declspec(dllexport) in the file. It should be similar to creating a .a file on linux, where anything not static to the files the library wa...

Parse out the file extension from a file-path in C

I was previously using the following code to determine if a file was an .exe or .o file and thus set binFile to 1: if(strstr(fpath,".exe") != NULL || strstr(fpath,".o") != NULL) binFile = 1; Through debugging, I noticed that this method will also set binFile to 1 with files like foo.out or foo.execute. What I really want is...

Unit testing for failed malloc()

What is the best way for unit testing code paths involving a failed malloc()? In most instances, it probably doesn't matter because you're doing something like thingy *my_thingy = malloc(sizeof(thingy)); if (my_thingy == NULL) { fprintf(stderr, "We're so screwed!\n"); exit(EXIT_FAILURE); } but in some instances you have choices o...

How do I improve the performance of SQLite?

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts-per-second to over 96 000 inserts-per-second! Background: We are using SQLite as part of a desktop application. We have large amounts of configuration data stored in XML files that are parsed and loaded into an SQLite database for further p...

sqrt from math.h causes compile error

So I've run into an interesting problem I've never seen before. I created a small program, as follows: #include <math.h> #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { int i; double tmp; double xx; for(i = 1; i <= 30; i++) { xx = (double) i + 0.01; tmp = sqrt(xx); ...

syntax error; unexpected symbol:

Hi! I'm making a bunch of c/src files, and get: syntax error; unexpected symbol: "EnableUART" It is referenced in a driver.c file and defined in a .src file. It is XDEF'd correctly, Here is the c snippet: int main() { EnableUART(0, 9600, 'N'); } Any ideas of why something gives this error? TYTY ...

Can't include dynamic library header file in more than one file?

I have successfully added a dynamic library to a program, but when I try to include the header file in a second file of the project I get errors about class redeclaration. I will add more info if this isn't enough ...

C\C++ open source Mp3 to PCM convertor

C\C++ open source Mp3 to PCM convertor? What do I need Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it, about etc. ...

Dividing a timeval by an integer in C

I'm trying to divide a timeval by an integer. Here's what I've got so far: #include <limits.h> #include <stdio.h> #include <stdlib.h> int main(void) { struct timeval my_time; struct timeval my_time_quotient; int i; gettimeofday(&my_time, NULL); i = 5; my_time_quotient = my_time / i; printf("%d secs...

C/C++ PCM open source audio analizer

C/C++ PCM opensource audio analizer? What do I need Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it, about etc. ...

Is C good for any projects beyond the command-line and learning?

This is not meant to be inflammatory or anything like that, but I am in the midst of learning C, and (think) I have a good handle on most of the basics. I've done all of the various book exercises: primes generators, Fibonacci generators, string manipulation, yadda yadda, but none of this is cool. What is the "bridge" between command li...

Is there a library that can open and search through a pdf file?

Is there a library that can open and search through a pdf file? Preferably in C, python or ruby... ...

Variably modified array at file scope

I want to create a constant static array to be used throughout my Objective-C implementation file similar to something like this at the top level of my ".m" file: static const int NUM_TYPES = 4; static int types[NUM_TYPES] = { 1, 2, 3, 4 }; I plan on using NUM_TYPES later on in the file so I wanted to put it in a variable. ...

How to determine storage type (SSD drive or HHD .mechanical drive), using C language

How can I, programmaticaly, read the hardware information of my drives? ...

What does "#include <sndfile.h>" mean?

What does "#include <sndfile.h>" mean? (Sorry I'm c\c++ nub) By the way I know ActionScript and HTML. ...

compiling on Windows and Linux

Hello, I am just looking for some guidelines, as this might seem like a very open question. I have a project that has been compiled using Visual Studio 2008 sp1. I have to compile so it will run linux using gcc 4.4.1 C99. It is a demo application that I didn't write myself. The source code is written so it can be cross-platform (linu...

Why doesn't gcc allow a const int as a case expression?

I was looking at this SO question and got to thinking about const ints versus #defines and realized I don't actually understand why the compiler can't deal with this. Could someone shed some light as to why the following code const int FOO = 10; int main(int argc, char** argv) { switch(argc) { case FOO: { printf("foo\n"...

C/C++ Integer Operation

I found by chance that int a = (h/2)*w+ ( (h+1)/2-h/2 ) * (w+1)/2 ; is equal to int b = (w * h + 1) / 2 ; when w and h are positive integers (assume no overflow). Can you show me why these 2 are the same? edit : integer -> positive integer. ...

c library function to get number of active threads

Hi everybody, I'm developing a multi threaded Unix application in C. Is there a simple way to get the count of the number of simultaneously active threads? I don't want to have to write the code to keep track of the number of active thread if it already can be done for me by the library! :-) I'm using POSIX pthreads, and I'm trying to ...