Search Results

Search found 739 results on 30 pages for 'preprocessor directives'.

Page 1/30 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Remove extra junk from C preprocessor?

    - by Brendan Long
    I'm trying to use the C preprocessor on non-C code, and it works fine except for creating lines like this at the top: # 1 "test.java" # 1 "<built-in>" # 1 "<command-line>" # 1 "test.java" The problem is that these lines aren't valid in Java. Is there any way to get the preprocessor to not write this stuff? I'd prefer not to have to run this through something else to just remove the first 4 lines every time.

    Read the article

  • Can I append to a preprocessor macro?

    - by JCSalomon
    Is there any way in standard C—or with GNU extensions—to append stuff to a macro definition? E.g., given a macro defined as #define quux_list X(foo) X(bar) can I append X(bas) so that it now expands as if I’d defined it #define quux_list X(foo) X(bar) X(bas)? I’m playing with discriminated/tagged unions along these lines: struct quux_foo { int x; }; struct quux_bar { char *s; }; struct quux_bas { void *p; }; enum quux_type {quux_foo, quux_bar, quux_bas}; struct quux { enum quux_type type; union { struct quux_foo foo; struct quux_bar bar; struct quux_bas bas; } t; }; I figure this is a good place for the X-macro. If I define a macro #define quux_table X(foo) X(bar) X(bas) the enumeration & structure can be defined thus, and never get out of sync: #define X(t) quux_ ## t, enum quux_type {quux_table}; #undef X #define X(t) struct quux_ ## t t; struct quux { enum quux_type type; union {quux_table} t; }; #undef X Of course, the quux_* structures can get out of sync, so I’d like to do something like this, only legally: struct quux_foo { int x; }; #define quux_table quux_table X(foo) struct quux_bar { char *s; }; #define quux_table quux_table X(bar) struct quux_bas { void *p; }; #define quux_table quux_table X(bas) (Well, what I really want to be able to do is something like member_struct(quux, foo) { int x; }; but I’m well aware that macros cannot be (re)defined from within macros.) Anyhow, that’s my motivating example. Is there a way to accomplish this? Boost.Preprocessor examples are fine, if you can show me how to make the X-macro technique work with that library.

    Read the article

  • add_header directives in location overwriting add_header directives in server

    - by user64204
    Using nginx 1.2.1 I am able to add multiple headers using add_header as follows: server { listen 80; server_name localhost; root /var/www; add_header Name1 Value1; <=== HERE add_header Name2 Value2; <=== HERE location / { echo "Nginx localhost site"; } } GET / HTTP/1.1 200 OK Name1: Value1 Name2: Value2 However I soon as I use the add_header directive inside location, the other add_header directives under server are ignored server { listen 80; server_name localhost; root /var/www; add_header Name1 Value1; <=== HERE add_header Name2 Value2; <=== HERE location / { add_header Name3 Value3; <=== HERE add_header Name4 Value4; <=== HERE echo "Nginx localhost site"; } } GET / HTTP/1.1 200 OK Name3: Value3 Name4: Value4 The documentation says that both server and location are valid context and doesn't state that using add_header in one prevents using it in the other. Q1: Do you know if this is a bug or the intended behaviour and why? Q2: Do you see other options to get this fixed than using the HttpHeadersMoreModule module?

    Read the article

  • What are the lengths/limits C preprocessor as a language creation tool? Where can I learn more about

    - by Weston C
    In his FAQ @ http://www2.research.att.com/~bs/bs_faq.html#bootstrapping, Bjarne Stroustrup says: To build [Cfront, the first C++ compiler], I first used C to write a "C with Classes"-to-C preprocessor. "C with Classes" was a C dialect that became the immediate ancestor to C++... I then wrote the first version of Cfront in "C with Classes". When I read this, it piqued my interest in the C preprocessor. I'd seen its macro capabilities as suitable for simplifying common expressions but hadn't thought about its ability to significantly add to syntax and semantics on the level that I imagine bringing classes to C took. So now I have a couple of questions on my mind: 1) Are there other examples of this approach to bootstrapping a language off of C? 2) Is the source to Stroustrup's original work available anywhere? 3) Where could I learn more about the specifics of utilizing this technique? 4) What are the lengths/limits of that approach? Could one, say, create a set of preprocessor macros that let someone write in something significantly Lisp/Scheme like?

    Read the article

  • The Bizarre Hidden Powers of the Preprocessor? [closed]

    - by ApprenticeHacker
    The preprocessor in C and C++ deserves an entire essay on its own to explore its rich possibilities for obfuscation. It is true that the C++ (and C) preprocessor can be used for a lot of powerful stuff. #ifdefs and #defines are often used to determine platforms, compilers and backends. Manipulating the code likewise. However, can anyone list some of the most powerful and bizarre things you can do with the preprocessor? The most sinister use of the preprocessor I've found is this: #ifndef DONE #ifdef TWICE // put stuff here to declare 3rd time around void g(char* str); #define DONE #else // TWICE #ifdef ONCE // put stuff here to declare 2nd time around void g(void* str); #define TWICE #else // ONCE // put stuff here to declare 1st time around void g(std::string str); #define ONCE #endif // ONCE #endif // TWICE #endif // DONE This declares different things based on how many times the header is included. Are there any other bizarre unknown powers of the C++ preprocessor?

    Read the article

  • C language preprocessor behavior

    - by khanna_param
    There are different kind of macros in C language, nested macro is one of them. Considering a program with the following macro #define HYPE(x,y) (SQUR(x)+SQUR(y)) #define SQUR(x) (x*x) Using this we can successfully compile to get the result. As we all know the C preprocessor replaces all the occurrence of the identifiers with the replacement-string. Considering the above example I would like to know how many times the C preprocessor traverses the program to replace the macro with the replacement values. I assume it cannot be done in one go.

    Read the article

  • Visual C++ preprocessor definitions

    - by alemjerus
    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 executes some javascript like sarahjessicaparker.js /to tomsrhinoplasty $(MAKUMBA_OBA) It would be great, if it just worked, but I never get a third parameter in my js. So the question is: how to pass a preprocessor definition to s script?

    Read the article

  • Documenting preprocessor defines in Doxygen

    - by Fire Lancer
    Is it possible to document preprocessor defines in Doxygen? I expected to be able to do it just like a variable or function, however the Doxygen output appears to have "lost" the documentation for the define, and does not contain the define its self either. I tried the following /**My Preprocessor Macro.*/ #define TEST_DEFINE(x) (x*x) and /**@def TEST_DEFINE My Preprocessor Macro. */ #define TEST_DEFINE(x) (x*x) I also tried putting them within a group (tried defgroup, addtogroup and ingroup) rather than just at the "file scope" however that had no effect either (although other items in the group were documented as intended). I looked through the various Doxygen options, but couldn't see anything that would enable (or prevent) the documentation of defines.

    Read the article

  • O&rsquo;Reilly Deal of the Day 10/June/2014 - AngularJS Directives

    - by TATWORTH
    Originally posted on: http://geekswithblogs.net/TATWORTH/archive/2014/06/10/orsquoreilly-deal-of-the-day-10june2014---angularjs-directives.aspxToday’s half-price E-Book offer from O’Reilly at http://shop.oreilly.com/product/9781783280339.do is AngularJS Directives. “AngularJS, propelled by Google, is quickly becoming one of the most popular JavaScript MVC frameworks available, working to invert the development paradigm and bring data-driven modularity to the web frontend. Directives serve as the core building blocks in AngularJS and enable you to create reusable models that mold around your data structures and breathe new life into the intersection of HTML and JavaScript.”

    Read the article

  • C++ Preprocessor string literal concatenation

    - by ezpz
    I found this regarding how the C preprocessor should handle string literal concatenation (phase 6). However, I can not find anything regarding how this is handled in C++ (does C++ use the C preprocessor?). The reason I ask is that I have the following: const char * Foo::encoding = "\0" "1234567890\0abcdefg"; where encoding is a static member of class Foo. Without the availability of concatenation I wouldnt be able to write that sequence of characters like that. const char * Foo::encoding = "\01234567890\0abcdefg"; Is something entirely different due to the way \012 is interpreted. I dont have access to multiple platforms and I'm curious how confident I should be that the above is always handled correctly - i.e. I will always get { 0, '1', '2', '3', ... }

    Read the article

  • organize using directives, re-run tests?

    - by Sarah Vessels
    Before making a commit, I prefer to run all hundred-something unit tests in my C# Solution, since they only take a couple minutes to run. However, if I've already run them all, all is well, and then I decide to organize the using directives in my Solution, is it really necessary to re-run the unit tests? I have a macro that goes through all files in the Solution and runs Visual Studio's 'Remove and Sort' command on each. In my understanding, so long as all projects still build after using directives are changed around, things should be fine at runtime, too. Is this correct thinking?

    Read the article

  • C language preprocessor behavior

    - by khanna_param
    There are different kind of macros in C language, nested macro is one of them. Considering a program with the following macro #define HYPE(x,y) (SQUR(x)+SQUR(y)) #define SQUR(x) (x*x) Using this we can successfully compile to get the result. As we all know the C preprocessor replaces all the occurrence of the identifiers with the replacement-string. Considering the above example I would like to know how many times the C preprocessor traverses the program to replace the macro with the replacement values. I assume it cannot be done in one go.

    Read the article

  • Use a template parameter in a preprocessor directive?

    - by Ranju V
    Is it possible to use a non-type constant template parameter in a preprocessor directive? Here's what I have in mind: template <int DING> struct Foo { enum { DOO = DING }; }; template <typename T> struct Blah { void DoIt() { #if (T::Doo & 0x010) // somecode here #endif } }; When I try this with something like Blah<Foo<0xFFFF>>, VC++ 2010 complains something about unmatched parentheses in the line where we are trying to use "#if". I am guessing the preprocessor doesn't really know anything about templates and this sort of thing just isn't in its domain. What say? Thanks!

    Read the article

  • Any other preprocessor directives in VBScript/Classic ASP?

    - by Frank
    The only pre-process directive that I know about in VBScript / Classic ASP is the #include. I don't know if that is the official name but I'm basically looking for code that can execute code or other instructions before the general VBScript. Are there any other such directives in VBScript? Such as #If or something? I'd like to be able to conditionally include or exclude a certain include file.

    Read the article

  • Writing preprocessor directives to get string

    - by Dave18
    Can you write preprocessor directives to return you a std::string or char*? For example: In case of integers: #define square(x) (x*x) int main() { int x = square(5); } I'm looking to do the same but with strings like a switch-case pattern. if pass 1 it should return "One" and 2 for "Two" so on..

    Read the article

  • Mimic C preprocessor with Python/Ruby?

    - by prosseek
    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 that I can change a variable that affects all the script files in a project?

    Read the article

  • gcc run "light" preprocessor

    - by Claudiu
    Is there any way to run the gcc preprocessor, but only for user-defined macros? I have a few one-liners and some #ifdef etc... conditionals, and I want to see what my code looks like when just those are expanded. As it is, the includes get expanded, my fprintf(stderr)s turn into fprintf(((__getreeent())-_stderr), etc...

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >