I'm writing system-level code for an embedded system without memory protection (on an ARM Cortex-M1, compiling with gcc 4.3) and need to read/write directly to a memory-mapped register. So far, my code looks like this:
#define UART0 0x4000C000
#define UART0CTL (UART0 + 0x30)
volatile unsigned int *p;
p = UART0CTL;
*p &= ~1;
Is t...
I am working in multithreading application, application is facing some problem while processing the request.
When i kept load on multithreaded application,it is working fine up to some time.After some time it is not able to process any request.At this situation when type this command,
ps -eLF | grep multithread
all threads are showing...
I'm learning the basics of writing a simple, efficient socket server using GLib. I'm experimenting with GSocketService. So far I can only seem to accept connections but then they are immediately closed. From the docs I can't figure out what step I am missing. I'm hoping someone can shed some light on this for me.
When running the follo...
Hello, I wrote a makefile:
all: server client
server: server.o des.o sha1.o
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o server server.o des.o sha1.o -I /usr/local/include/ -lgmp
client: client.o des.o sha1.o
/usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o -lgmp client client.o des.o sha1.o -I /usr/local/include/
s...
I have the following code:
struct treenode;
typedef struct treenode* TreeNode;
struct treenode {
void* data;
TreeNode left, right;
};
TreeNode newTreeNode(void* data){
TreeNode node = (TreeNode) malloc(sizeof(struct treenode));
node->data = data;
node->left = NULL;
node->right = NULL;
return node;
}
bool insert(Tre...
I am pretty new to Ubuntu, but I can't seem to get this to work. It works fine on my school computers and I don't know what I am not doing. I have checked usr/include and time.h is there just fine. Here is the code:
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
timespec time1, time2;
int temp;
c...
I'm working on project involving c programming for my mathematics course at university.
I need to be able to handle large integers, larger than those that can be stored in a 'long int' datatype. So I tried using 'long long int', but if I try something like this:
long long int number;
number = 10000000000;
Then the error message says ...
I'm calling the following function to try to clear the system clipboard:
GtkClipboard *clipboard;
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
gtk_clipboard_clear(clipboard);
however it's not cleaning anything. I've searched the Gnome and GTK+ documentations and countless sample code snippets and I've no idea how to do thi...
I'm trying to create a dynamic popup menu within my application, the generation code I use is something like that :
HMENU menu;
POINT pt;
menu = CreatePopupMenu();
SetForegroundWindow( receivingWindow );
GetCursorPos( &pt );
int i = 19;
AppendMenu( menu, MF_STRING, i++, _TEXT("meh meh") );
AppendMen...
#include<stdio.h>
#include<signal.h>
void handler(int signo)
{
printf("Into handler\n");
while(1);
}
int main()
{
struct sigaction act;
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(& act.sa_mask);
sigaction(SIGINT, &act, NULL);
while(1);
return 0;
}
After catching the KeyboardInterrupt on...
How can I get the CPU clock speed in C++?
I am running Ubuntu 9.10 if that makes any difference.
...
Signals seem to be one of those areas that should be conceptually simple and easy to explain but I have never come across one source that is both comprehensive, lucidly written, and up to date. In part this seems to be because of historical cruft, lots of exceptions to rules, different programming standards, the confusion threads throw ...
I've been going through the dll walkthrough on MSDN and it works fine. I then removed all the C++ style code in the dll and replaced it with the C equivalent, and it still works.
BUT, when I rename the file from X.cpp to X.c (which I guess causes compilation in C-mode), I get error LNK2019 (unresolved external symbol) for every functio...
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
void handler(int signo)
{
printf("First statement");
system("date");
exit(EXIT_SUCCESS);
}
int main()
{
signal(SIGINT,handler);
printf("Waiting for KeyboardInterrupt\n");
for(;;);
return 0;
}
Test run:-
shadyabhi@shadyabhi-desktop:~/c$ gcc main.c
shad...
I am working on a program in C and using the SDCC compiler for a 8051 architecture device.
I am trying to write a function called GetName that will read 8 characters from Flash Memory and return the character array in some form. I know that it is not possible to return an array in C so I am trying to do it using a struct like this:
//*...
For some reason if I try to get the actual size of mystruct I keep getting size 1.
I know that mystruct is holding the data cause I can dump it out and everything is in mystruct.
What could be the reason of getting size 1?
Thanks
// fragments of my code
struct mystruct {
char *raw;
int count;
};
struct counter {
int tot...
I compiled a simple hello world C module for Python and it works correctly in everything I've tried but IDLE. Here's what I type to test it:
>>> import hello
>>> hello.say_hello('Justin')
I have tried this using Python from the command prompt(I'm using Windows), in Eclipse's PyDev, and with PieDream and they all print out Hello Justin...
So, I'm using the FMOD api and it really is a C api.
Not that that's bad or anything. Its just it doesn't interface well with C++ code.
For example, using
FMOD_Channel_SetCallback( channel, callbackFunc ) ;
It wants a C-style function for callbackFunc, but I want to pass it a member function of a class.
I ended up using the Win32...
This is a stupid question. :)
[EDIT: stupid or not, this turned out to be a C++ peculiarity question, see UPDATE_2]
Suppose we have:
int a = 0; // line 1
int b = ++a; // line 2
What happens in line 2 is (note, numbers are just markers and do not specify exact order):
= [1: write result of (3) to result of (2)...
Consider this code:
void res(int a,int n)
{
printf("%d %d, ",a,n);
}
void main(void)
{
int i;
for(i=0;i<5;i++)
res(i++,i);
//prints 0 1, 2 3, 4 5
for(i=0;i<5;i++)
res(i,i++);
//prints 1 0, 3 2, 5 4
}
Looking at the output, it seems that the arguments are not evaluated from right to left eve...