The theoretical maximum of memory bandwidth for a Core 2 processor with DDR3 dual channel memory is impressive: According to the Wikipedia article on the architecture, 10+ or 20+ gigabytes per second. However, stock memcpy() calls do not attain this. (3 GB/s is the highest I've seen on such systems.) Likely, this is due to the OS vend...
I have a function in which one of the function arguments is an integer. During function invocation I am passing an enumerated datatype to this function. After building using gcc, any access to the INTEGER variable inside the function causes a segmentation fault.
Sample code:
void somefun (unsigned int nState)
{
switch (nState) // <...
What are the C logging API's out there?
Some of them I found are
log4c
pantheios
lwl
Is anyone aware of other loggers.
Thanks.
...
Can someone tell me how I can use the rolling log feature of log4c API library.
There is only documentation on functions it provides and there are so many
if anyone has used rolling log with log4c , would be great to see how to configure it and use it.
thanks.
...
How can I efficiently catch and handle segmentation faults from C in an OSX Carbon application?
Background: I am making an OSX Carbon application. I must call a library function from a third party. Because of threading issues, the function can occasionally crash, usually because it's updating itself from one thread, and it's got some in...
I often find that the headers section of a file get larger and larger all the time but it never gets smaller. Throughout the life of a source file classes may have moved and been refactored and it's very possible that there are quite a few #includes that don't need to be there and anymore. Leaving them there only prolong the compile time...
I have made a window with CreateWindowEx() function, now how do i get the width and height from that window i created? This sounds very basic thing to do, but i just couldnt find any answer ;_;
This is needed because the window height is created automatically depending on how the Windows wants to create it.
Language C or C++
...
I have the following in a program (part of a much larger function, but this is the relevant testing bit):
int test = 100 + (100 * (9 / 100));
sprintf (buf, "Test: %d\n\r", test);
display_to_pc (buf, player);
Basically it amounts to:
x = a + (a * (b / 100))
Where a is a given figure, b is a percentage modifier, and x is the result (...
I'm having trouble compiling the example program presented in section 5.11 of the book. I have removed most of the code and left only the relevant stuff.
#define MAXLINES 5000
char *lineptr[MAXLINES];
void qsort1(void *lineptr[], int left, int right, int (*comp)(void *, void *));
int numcmp(char *, char *);
main(int argc, char *argv[]...
Hey guys. I'm not new to programming but I am a beginner at C and C++ coding. I only know the basics of the C language and how to write small and simple programs so far. I'm not interested in learning C++ for the long haul but I am interested in becoming a fluent C programmer. My predicament is adjusting to the MS Visual Studio 2008 envi...
Using the Win32 APIs, is it possible to create a Window or Dialog in one thread then collect events for it from another thread?
Are HWNDs tied to threads?
Trying the contrived example below I never see GetMessage() fire.
HWND g_hWnd;
DWORD WINAPI myThreadProc(LPVOID lpParam)
{
while(GetMessage(
CreateThread(NULL, 0 myThreadP...
I was just using gdb to print out a value of a double and to my surprise it printed -0
What is a double of -0 value mean in C?
By the way when I checked it's equality with 0 it returned true: To do the comparison I just did the following
in gdb
> print some_double
-0
> print some_double == 0
1
...
I want to override certain function calls to various APIs for the sake of logging the calls, but I also might want to manipulate data before it is sent to the actual function.
For example, say I use a function called getObjectName thousands of times in my source code. I want to temporarily override this function sometimes because I want...
Whenever BOOL datatype is not readily predefined, I used to boolean with the following definition,
typedef unsigned char BOOL;
(Owing to memory usage).
I realized it may be better to use native bus width for performance reasons. For example, for a 32 bit processor it can be
typedef unsigned int BOOL;
Now, what will happen for the 64...
How can I write a program in C which removes all the defined values defined by the user using #define name value?
Throughout the program should we replace the name, value?
Does anyone have any examples of this?
...
Hey,
so as per one of my previous questions, I'm brushing up on my C skills.
My question is, what do people use for developing C?
Lots of people use Emacs, and have done so for years, but is it better to learn emacs than just use an IDE such as Geany or KDevelop?
Would also be interested to hear from those still using emacs, and why ...
For a debugging and logging library, I want to be able to find, at runtime, a list of all of the source files that the project has compiled and linked. I assume I'll be including some kind of header in each source file, and the preprocessor __FILE__ macro can give me a character constant for that file, so I just need to somehow "broadcas...
How can I access a shadowed global variable in C? In C++ I can use :: for the global namespace.
...
I have a simple WinCE network application (in C, Win32 APIs). I find that networking doesn't seem to work unless I launch IE (or another network app) first. I assume that IE is setting up my network interface in some way.
How can I do this for myself?
Might I need to display a list of available interfaces to the user (eg. WiFi/Ethernet...
Hello,
I'm trying to understand what's going wrong with a program run in HP-UX 11.11 that results in a SIGSEGV (11, segmentation fault):
(gdb) bt
#0 0x737390e8 in _sigfillset+0x618 () from /usr/lib/libc.2
#1 0x73736a8c in _sscanf+0x55c () from /usr/lib/libc.2
#2 0x7373c23c in malloc+0x18c () from /usr/lib/libc.2
#3 0x7379e3f8 in _fi...