Howdy!
I am hoping that someone may have an idea on how to control/specify the order of macro expansion. Here is the context:
// 32 bit increments, processor has registers for set, clear and invert
#define CLR_OFF 1
#define SET_OFF 2
#define INV_OFF 3
#define SET(reg,bits) *((volatile unsigned long*)(
SET(LATB, STATUS_LED); // LATB...
What would the equivalent in C/C++?
...
Hi,
I am trying to call a C++ class and its method from a c file.
I google this topic and find this http://developers.sun.com/solaris/articles/mixing.html
It says "
You can write extern "C" functions in C++ that access class M objects and call them from C code. Here is a C++ function designed to call the member function foo:
extern ...
In union we know the memory used is maximum of the one occupied by its element but how on the same memory space different elements of the union can be stored ,are they not overwritten on the same memory space which cause to lose the prior element present there,i actually want to know the exact working of union while storing the different...
I'm trying to write a program to randomly generate music based on a simple set of rules. I would like the program to be able to generate its own sounds, as opposed to having a file with audio for each note. Does anyone know a simple way of doing this? It would be nice (but not essential) for the sound to be polytonal, and I would like a ...
Background:
I am writing a GLFW app on MacOSX. When I call glfwCreateWindow, the MacBundle stuff is called. Right now, in my program execution, I ahve the following:
// getcwd() = /Users/me/code
glfwCreateWindow(...); // some MacBundle stuff happens
// getcwd() = /Users/me/code/prog.app/Contents/Resources
I would like to control this...
I’m trying to determine the relationship of a given compiler’s integer types’ sizes using the preprocessor. My requirement is that I have two types, one of which is unsigned, and one of which is a signed type capable of storing every positive number that said unsigned type can store. i.e. I have to ensure that my ll_ssize type can store ...
I'm writing a 'C' program that makes several calls to system() to execute other programs. When constructing the command string is it better to explicitly give the full path to the program being called, or should I just give the executable name and let the shell resolve its location using the PATH environment variable?
The programs I'm c...
I'm designing a recursive algorithm :
int f(int[] a, int[] b){
----changing a here
----changing b here
f(a,b)
----writing a here
----writing b here
}
I know all arrays are pointers so this code should be problematic. It'll write the final values of a and b after all the recursive calls finished. I dont want that to happen.
What shoul...
In solaris how to detect broken socket in send() call? i dont want to use signal.
i tried SO_NOSIGPIPE and MSG_NOSIGNAL but both are not available in Solaris and my program is getting killed with "broken pipe" error.
Is there any way to detect broken pipe?
Thanks!
...
Please check the following code
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#define CLOCKID CLOCK_REALTIME
#define SIG SIGRTMIN
int reset = 0;
void changemode(int);
int kbhit(void);
int pfds[2];
s...
I’m using a pair of global variables in one of my .c files, matched to a single extern declaration each in two different .h files (well, one .h file, preprocessed two ways). One is for public consumption, and one is for private use. Both are const variables.
I only want to initialize one of the variables in my .c file, and then assign t...
I'm using the write() function to write to a socket in C. I am not a C expert, and sometimes I know this function can fail, in those cases it can return some kind of SIGPIPE.
Here's the simple piece of code I'm using now:
if(write(sockfd, sendline, sizeof(sendline)) < sizeof(sendline))
{
printf("Failed to write string %s t...
Hello,
In my application, I have a char array defined which can take one of three options: "okay", "high", "low" which are then sent down a serial port to a remote device. I currently have the array sized to take the 4 character words plus carriage return and line feed, but when I have to send "low" I get a null character in the string...
Possible Duplicate:
Can a recursive function be inline?
What are the trade offs of making recursive functions inline.
...
This is a cut down example of a much larger project. You can see it here.
I have a header file containing the limits of the system time functions. Call it time_config.h.
#ifndef TIME_CONFIG_H
#define TIME_CONFIG_H
#define HAS_TIMEGM
#define SYSTEM_LOCALTIME_MAX 2147483647
#define SYSTEM_LOCALTIME_MIN -2147483...
what is data(number), if the required output from the following statement is is : AMAZING?
main()
{
int data;
if(data!=0 && data==-data)
{
printf("AMAZING");
}
}
...
I'm creating a program which follows certain rules to result in a count of the words, syllables, and sentences in a given text file.
A sentence is a collection of words separated by whitespace that ends in a . or ! or ?
However, this is also a sentence:
Greetings, earthlings..
The way I've approached this program is to scan through t...
Hello all,
I have this class with an instance method named open and need to call a function declared in C also called open. Follows a sample:
void SerialPort::open()
{
if(_open)
return;
fd = open (_portName.c_str(), O_RDWR | O_NOCTTY );
_open = true;
}
When I try to compile it (using GCC) I get the following erro...
Consider the following code:
#include <stdio.h>
int main(void)
{
int a[10];
printf("%d",(int)sizeof(a)); //prints 10*sizeof(int) (40 on my compiler)
printf("%d",(int)sizeof(a-3)); //prints sizeof(int) (4 on my compiler)
}
I know that sizeof() is a compile time operator but I was surprised to see the output of seco...