Hi,
I have a bunch of C macros the operation of which I need to simulate in python. I saw some pointers to pygccxml or ctypeslib etc. Are these the ways to go ? Or is there something out there that is better ?
The C macros if and when they change, I would like the python implementation to be auto generated rather than having to make ma...
I'm trying to detect the compiler used to compile my source code. I can easily find predefined macros to check for MSVC or GCC (see http://predef.sourceforge.net/ for example), but I cannot find any macro to check for clang.
Does someone know if clang defines a macro like __CLANG__ in order to know what is currently compiling my code ?
...
Is there a way to transfer C++ preprocessor definitions into a custom pre-link step procedure call as a command-line parameter or export them into a file any other way?
Example:
Let's say, I have a c++ project, and in it's Debug configuration I put a preprocessor definition like MAKUMBA_OBA=0x13
Then I add custom pre-link step which exec...
i am trying to use following pattern.
#ifndef TRACER_H
#include "Tracer.h"
#endif
This is statement is added to each file in the code such that tracer.h is added only once.
Still i am getting an error saying multiple objects
Also Tracer.h contains
#ifndef TRACER_H
#define TRACER_H
here is the error
i tried prgma onece as well
1>G...
Is it possible to put a macro in a macro in c++?
Something like:
#define Something\
#ifdef SomethingElse\ //do stuff \
#endif\
I tried and it didn't work so my guess is it doesn't work, unless there's some sort of syntax that can fix it?
...
The standard includes macros line __LINE__ & __FILE__, and C99 adds __FUNCTION__ which is technically not part of C++ yet.
What additional ones does MSVC++ add which are useful/cool? I found __FUNCTION__ is supported but are there any other totally MS-specific ones worth knowing about?
...
I can use __LINE__ as a method parameter just fine, but I would like an easy way to use it in a function that uses strings.
For instance say I have this:
11 string myTest()
12 {
13 if(!testCondition)
14 return logError("testcondition failed");
15 }
And I want the result of the function to be:
"myTest line 14: ...
I generally have ignored using macros while writing in C but I think I know fundamentals about them. While i was reading the source code of list in linux kernel, i saw something like that:
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
(You can access the re...
In this maximally clipped source example, the manifest constant FOOBAR is being redefined. This is deliberate, and there is extra code in the live case to make use of each definition.
The pragma was added to get rid of a warning message, but then a note appeared, and I don't seem to find a way to get rid of the note.
I've been able to ...
I need to mimic the preprocessor feature of C with Python.
If I want to run the debug release, I use as follows with C
#ifdef DEBUG
printf(...)
#endif
I just use -DDEBUG or similar to trigger it on or off.
What method can I use for Python/Ruby?
I mean, what should I do to control the behavior of python/ruby scripts in such a way th...
I have many (~100 or so) filter coefficients calculated with the aid of some Matlab and Excel that I want to dump into a C header file for general use, but I'm not sure what the best way to do this would be. I was starting out as so:
#define BUTTER 1
#define BESSEL 2
#define CHEBY 3
#if FILT_TYPE == BUTTER
#if FILT_ROLLOFF == 0.010...
Here is some C++ code I'm playing around with:
#include <iostream>
#include <vector>
#define IN ,
#define FOREACH(x,y) for(unsigned int i=0;i<y.size();i++) { x=y[i];
#define ENDFOREACH }
using namespace std;
int main()
{
vector<int> ints;
ints.push_back(3);
ints.push_back(4);
ints.push_back(5);
ints.push_back(6);
...
I have the following 2 macros:
#define SCOPED_ENUM_HEADER(NAME) struct NAME{ enum _NAME{
#define SCOPED_ENUM_FOOTER(NAME) };}; typedef NAME::_NAME NAMEtype;
Only the first instance of NAME get replaced by the passed NAME. What's wrong with it?
Is is to be used in such a way:
SCOPED_ENUM_HEADER(LOGLEVEL)
UNSET,
FILE,
SCREEN...
Is it possible in C# to set such a condition that if the condition is true - compile one file;If condition is false - compile another file?
Sort of like
#ifdef DEBUG
#include Class1.cs
#else
#include Class2.cs
#endif
Or possibly set it up in project properties.
...
I have a bunch of MACROS in c++ code that expand into some functions. And I am debugging something. Just want to see what the code ends up looking like”
Any ideas?
...
Hi all,
I have some fairly generic code which uses preprocessor macros to add a certain prefix onto other macros. This is a much simplified example of what happens:
#define MY_VAR(x) prefix_##x
"prefix_" is actually defined elsewhere, so it will be different each time the file is included. It works well, but now I have some code I ...
Whlie reading codes of my group project, I come across many DEFINEs, and some of them seems strange. To generalize it, please look at the following 2 examples.
Example 1:
#define SNPRINTF(dst, fmt, arg...) snprintf(dst, sizeof(dst), fmt, ##arg)
what does "##" means in this circumstance? I've tried to delete both of them, and wri...
I am building using zlib.h which I have a local copy to v1.2.5, but in /usr/include/zlib.h there is v1.2.1.2.
If I omit adding -I/my/path/to/zlib to my make I get error from using old version which doesn't have Z_FIXED:
g++ -g -Werror -Wredundant-decls -D_FILE_OFFSET_BITS=64 -c -o ARCH.linux_26_i86/debug/sysParam.o sysParam.cpp
sysPara...
What does '#if _LFS64_LARGEFILE-0' mean to the C Preprocessor for g++? Is that a minus zero or is that part of the symbol? If it is minus zero, how does that affect whether the #if is triggered?
...
Help settle the debate that's going on in the comments at this question about bool and 1:
Can a standards-conforming C++ preprocessor allow one to use #define to redefine a language keyword? If so, must a standards-conforming C++ preprocessor allow this?
If a C++ program redefines a language keyword, can that program itself be standard...