Hi all,
I have a simple memory mapped interface, and I would like to write through
this values to two registers and then read them back. The following code
example works fine:
volatile int *reg1 = (int *) 0x80000000;
volatile int *reg2 = (int *) 0x80000004;
*reg1 = 12; *reg2 = 23;
printf("reg1 = %i\n", *reg1);
printf("reg...
Is it possible with gcc to eliminate the warning below without eliminating all warnings?
pasting "/" and "/" does not give a valid preprocessing token
For a certain platform, I must use a specific cross-compiler, but I can use make, so I use gcc to create the dependencies.
I know that I'm passing the “//” token to the compiler and it’...
Hello,
I have a C-program (an Apache module, i.e. the program runs often), which is going to write() a 0-terminated string over a socket, so I need to know its length.
The string is #defined as:
#define POLICY "<?xml version=\"1.0\"?>\n" \
"<!DOCTYPE cross-domain-policy SYSTEM\n" \
"\"http://www.adobe.com/xml/dtds/cross-domain-p...
A few questions about the C++ preprocessor:
how to make the preprocessor go to a new line into the preprocessoring code?
how to make the preprocessor insert a tab character or multiple spaces into the preprocessoring code?
how to make the preprocessor insert comments into the preprocessoring code?
...
Is it possible to write a Macro (using token concatenation) that returns fmt for printf ?
Eg.
#define STR_FMT(x) ...code-here...
STR_FMT(10) expands to "%10s"
STR_FMT(15) expands to "%15s"
...
etc.
So that I can use this macro inside a printf:
printf(STR_FMT(10), "*");
...
Here's the situation:
I have three files, Test1.cpp and Test2.cpp. Test1.cpp can be compiled as-is into a stand-alone application. Test1.cpp also contains some functions that I would like to re-use in Test2.cpp. I'm using an #ifndef #endif block to conditionally exclude the main function of Test1.cpp so that when I compile Test2.cpp, ...
Is it possible to determine the line number that calls a function without the aid of a macro?
Consider this code:
#include <iostream>
#define PrintLineWithMacro() \
std::cout << "Line: " << __LINE__ << std::endl; // Line 4
void PrintLine()
{
std::cout << "Line: " << __LINE__ << std::endl; // Line 8
}
int main(int argc, char ...
I want to have a C preprocessor macro that knows the number of instantiations/macro calls of this macro so far.
Example:
int main() {
printf("%d\n", MACRO());
printf("%d\n", MACRO());
}
Should print
0
1
Is something like this possible?
Note that it is not enough to forward this to a function as proposed below.
It should work i...
Hi,
I want to know how to find out if the preprocessor macro __PRETTY_FUNCTION__ can be used with a given compiler (As it is supposed to be non-standard). How do I check this in a header file? What I want to do is something like:
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __func__
#endif
But, I'm guessing what happ...
I have a string:
B<T>::B() [with T = int]
Is there any way I can get
B<T> [with T = int] from this before run time somehow? :)
EDIT:
Simplifying: Is there any way to get X & Y separately from a static string XY defined as a preprocessor macro in any form before runtime?
...
Is this a stupid question? Or can I specify g++ to use a program between the preprocessor and compiler?
Alternatively, I know that I can just run the preprocessor on a file (hence all the files). Then I am guessing there is a switch to run only the compiler. So I can manually invoke these two and put my program between. If so, how do I ...
Hello,
the title could be somewhat misleading so let me explain what I'm trying to achieve.
I'm writing a programming language that has a plethora of operators which can work on multiple types with different behaviour. The implementation is evolving and operators are changing/adapting to what I find more useful while trying it.
The pro...