c

where can I find a prime forum for gtk+ (c++) type questions?

I am sorry if it defeats the purpose of this forum, but I see very limited GTK activity here and would like get heavily involved in it. What is the prime forum(s) where GTK is discussed. I use it primarily with c/c++. ...

Import active preprocessor symbols from file into Eclipse CDT

I'm using Eclipse CDT for a C project with custom makefiles, and I want to use the inactive code highlighting as proposed in the answers to question 739230. The automatic discovery of active/defined symbols does not work for my makefiles. Instead I have created a text file for each build target listing the active symbols. So my question...

C/C++ call-graph utility for Windows platform

I have a large 95% C, 5% C++ Win32 code base that I am trying to grok. What modern tools are available for generating call-graph diagrams for C or C++ projects? ...

C/C++, can you #include a file into a string literal?

I have a C++ source file and a Python source file. I'd like the C++ source file to be able to use the contents of the Python source file as a big string literal. I could do something like this: char* python_code = " #include "script.py" " But that won't work because there need to be \'s at the end of each line. I could manually copy a...

Where can I find a good example GAsyncQueue usages between process and thread

Beyond explanation of GAsyncQueue I cannot find anything on how to use this data structure, examples, patterns. I am trying to use to as a IPC mechanism between thread and the main process. Can someone demonstrate it? Thanks ...

char[] (c lang) to string (c++ lang) conversion

I can see that almost all modern APIs are developed in the C language. There are reasons for that: processing speed, low level language, cross platform and so on. Nowadays, I program in C++ because of its Object Orientation, the use of string, the STL but, mainly because it is a better C. However when my C++ programs need to interact w...

How do you know how much space to allocate with malloc()?

I'm a total C newbie, I come from C#. I've been learning about memory management and the malloc() function. I've also came across this code: char *a_persons_name = malloc(sizeof(char) + 2); What I don't understand is how much space this is allocating for a_persons_name. Is it allocating 2 characters (eg. AB) or something else? I als...

How do you allow spaces to be entered using scanf?

Using the following code: char *name = malloc(sizeof(char) + 256); printf("What is your name? "); scanf("%s", name); printf("Hello %s. Nice to meet you.\n", name); A user can enter their name but when they enter a name with a space like Lucas Aardvark, scanf() just cuts off everything after Lucas. How do I make scanf() allow spaces...

Fastest path to Lua SHA256 RFC-2104 compliant HMAC signature?

I'm running Debian Linux, and for a Lua script I need to create a SHA256 checksum to authenticate requests to Amazon Web Services. They don't say for sure but it looks as if they may want a base64 encoding of the resulting SHA256 checksum. I'd be happy if someone had done a Lua binding. I'd be content if someone could help me figure o...

Tricky include situation in C

I have a file named cpu.h that includes two other headers named register.h and addrmode.h. A cpu_t struct is defined in cpu.h that the two includes need for their functions. I try to include cpu.h in the two other include files, but nothing is included. I am guessing they are not included because of the include guards set up in cpu.h. Do...

How to measure mutex contention?

I have some threaded code using PThreads on Linux that, I suspect, is suffering from excessive lock contention. What tools are available for me to measure this? Solaris has DTrace and plockstat. Is there something similar on Linux? (I know about a recent DTrace port for Linux but it doesn't seem to be ready for prime time yet.) ...

How to create a case insensitive Glib Hash Table?

Is there any simply way how to create a case insensitive (String -> String) Glib Hash Table? The result should fit this: GHashTable *table; //there should be definition of table g_hash_table_insert(table, "KeY", "Something"); //insert //every command should return the line in table g_hash_table_lookup(table, "Key"); g_hash_table_look...

Incorrect MacOSX select() behaviour on non-blocking connect

I'm playing with the socket layer in my cross platform framework and I'm trying to get the connect's to work in a non-blocking fashion. However after pouring over the docs they just don't seem to be behaving correctly at all. The heart of the problem is that after initiating a non-blocking connect the following select failes to notice th...

Get GCC to preserve an SSE register throughout a function that uses inline asm

I'm writing a program in C that needs to do some fast math calculations. I'm using inline SSE assembly instructions to get some SIMD action (using packed double precision floating point numbers). I'm compiling using GCC on Linux. I'm in a situation where I need to loop over some data, and I use a constant factor in my calculations. I'd ...

Using VS2008 with C/C++

I've decided to dive into some code written in C and I'd like to use VS I have VS08 Pro which I'm using now primarily for C#, but I've noticed that there are no options for C in VS. Also I've noticed that although VS has projects, and whatnot for C++ that the build options are all greyed out so I cannot build C++. What do I need to bui...

How Do I Build My First PHP Extension in C on Linux GCC?

I haven't used C since the 1980s and 1990s with my own experimentation. I'd like to be able to pick it up again, but this time by building small things in it and then loading it into PHP on Linux. Does anyone have a very short tutorial for me to make a foo() function in C as a shared object extension loaded in a php.ini? I assume I'll n...

Visual Studio 2008 not showing member values of structure pointer

I'm writing C code and sometimes when debugging, Visual Studio 2008 will not display any data when I hover over certain variables. It seems random, and although it's seldom, I'm in a tough spot when it does happen. Does anyone know how to fix or avoid this? Thank you very much! ...

What programming errors is this page highlighting?

http://dspace.dial.pipex.com/town/green/gfd34/art/bloopers.html The first one seems simple; return strcpy(malloc(strlen(s)), s); malloc could return null, and strcpy could try to copy data to memory address 0. Or s could be a pointer to a string (rather than an array), and malloc would only allocate enough space for a pointer, and ...

Am I "wasting" my time learning C and other low level stuff ?

I have just recently started learning C and the reason I did that was because frankly, I consider myself to be of a "less-developer" than the people who know and work with C. Thus I planned to start learning ASM, C, C++ and bought the K&R book and started pushing myself to learn the C Programming Language and up till now I'm doing great...

In C, what does "public" mean when put before a global variable?

I'm going through the source code of the "less" unix tool by Mark Nudelman, and the beginning of main.c has many of the following: public int logfile = -1; public int force_logfile = FALSE; public char * namelogfile = NULL; etc. in the global scope, before the definition of main(), What does public mean in this context? And more ...