Search Results

Search found 347 results on 14 pages for 'preprocessor'.

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

  • Java Preprocessor in C#

    - by Olaseni
    Say I want to create a sort of Pre-processor for existing java code, so I can get the language specific keywords and objects, and then create routines that convert them to their Csharp equivalents, using Csharp code - what route should this take? I'm thinking of Regular Expressions, but I'm fuzzed. I have a bunch of about a 100 .java files and I need to convert them to csharp code in record time. I have manually done just about five of them and I have serious headaches already. Or are there any tools out there that already do that?

    Read the article

  • How to define a preprocessor symbol in Xcode

    - by Steph Thirion
    Is it possible to set a symbol for conditional compilation by setting up properties in an Xcode project? My aim is to to create a symbol that is available to all files, without having to use import/include, so that a set of common classes can have a special behavior in some projects. Like the following, but with my own symbols. #if TARGET_IPHONE_SIMULATOR ... #endif

    Read the article

  • Preprocessor macros: how to insert arguments?

    - by mhambra
    Hi all, the code has a number of following sections: int filter; #ifdef INPUTFILTER_FOO LOG4CXX_DEBUG(log, "FOO filter used"); filter = F_FOO; #endif They are used multiple times in the code (used to provide I/O, threading support etc for all testing configurations), Circa they are essential for debugging but make the code look harsh, want to replace them with macros, one for each category_type namespace. So, want to expand the following: MACROSTUFFBAZ(log2, stuff, "BAZ") <- the text part is unique for each class, so it needs to be included in macro too. to: #ifdef INPUTSTUFF_BAZ LOG4CXX_DEBUG(log2, "BAZ stuff used"); stuff = S_BAZ; #endif To define macros, plan to use this: debug.hpp: #ifdef INPUTSTUFF_BAZ #define MACROSTUFFBAZ ... #else #define MACROSTUFFBAZ .. no code! #endif #endif (at least this will give a clear overview of the things currently undergoing probation, without seeing them around the code)

    Read the article

  • C Preprocessor: #define in C... advice

    - by vikramtheone
    Hi Guys, I'm making a big C project and I have never come across a situation like this before so, I need your advice. What is your opinion? Is it okay to have the constants defined within conditional preprocessors like I have done below or you advise me to do this some other way? Any drawbacks if I do it this way? Regards Vikram #define NUM_OCTAVES_4 //#define NUM_OCTAVES_5 #ifdef NUM_OCTAVES_4 #define OCTAVES 4 const unsigned char borders [4] = {11, 26, 50, 98}; #elif NUM_OCTAVES_5 #define OCTAVES 5 const unsigned char borders [5] = {11, 26, 50, 98, 194}; #endif

    Read the article

  • Reliably converting C preprocessor macros to python code

    - by manual-manuel
    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 manual modifications. Hence the question. <my_c_header.h> /* #defines type 1 */ #ifdef OS #define NUM_FLAGS (uint16_t)(3) #define NUM_BITS (uint16_t)(8) #else #define NUM_FLAGS (uint16_t)(6) #define NUM_BITS (uint16_t)(16) #endif #define MAKE_SUB_FLAGS (uint16_t)((1<<NUMFLAGS) -1) #define MAKE_TOTAL_FLAGS(x) (uint16_t)((x & MAKE_SUB_FLAGS) >> NUM_BITS) /* #defines type 2 */ #ifdef OS #DO_SOMETHING(X) os_specifc_process(x) #else #DO_SOMETHING(x) #endif /* #defines type 3 */ enum { CASE0, CASE1, CASE2 } #define MY_CASE_0 ((uint16_t)CASE0) #define MY_CASE_1 ((uint16_t)CASE1) #define MY_CASE_2 ((uint16_t)CASE2) #define /*End of file <my_c_header.h> */ Thanks M

    Read the article

  • [MSVC++ 2008] Using preprocessor directives to define command line options

    - by Gbps
    If I wanted to add, let's say, a new .lib to the build only if a particular #define was set, how would I do that? In the MSVC++ 2008 "Property Pages", you would simply add: Config Properties -> Linker -> Input -> Additional Dependencies, but I would like it if something like #define COMPILE_WITH_DETOURS was set, then the particular library would be added to the dependencies, otherwise it would be removed. Thanks!

    Read the article

  • Preprocessor directive #ifndef for C/C++ code

    - by Leif Andersen
    In eclipse, whenever I create a new C++ class, or C header file, I get the following type of structure. Say I create header file example.h, I get this: /*Comments*/ #ifndef EXAMPLE_H_ #define EXAMPLE_H_ /* Place to put all of my definitions etc. */ #endif I think ifndef is saying that if EXAMPLE_H_ isn't defined, define it, which may be useful depending on what tool you are using to compile and link your project. However, I have two questions: Is this fairly common? I don't see it too often. And is it a good idea to use that rubric, or should you just jump right into defining your code. What is EXAMPLE_H_ exactly? Why not example.h, or just example? Is there anything special about that, or could is just be an artifact of how eclipse prefers to autobuild projects? Thank you for your help.

    Read the article

  • Preprocessor not skipping asm directives

    - by demula
    I'm programming to a microprocessor (Coldfire) and I don't have access every day to the microprocessor trainer so I want to be able to execute some of my code on the computer. So I'm trying to skip a part of my code when executing on the computer by defining _TEST_. It doesn't work. It tries to compile the asm code and dies whining about not knowing the registers names (they're defined alright compiling against the Coldfire, not my Intel Core Duo). Any ideas why it's not working? or maybe an alternative way to run the code on the pc without commenting it out?. Here's sample code from my project: inline void ct_sistem_exit(int status) { #ifdef _TEST_ exit(status); #else asm volatile( "moveb #0,%%d1\n\t" "movel #0, %%d0\n\t" "trap #15\n\t" : : : "d0", "d1" ); #endif /* _TEST_ */ } If it helps: using gcc3 with cygwin on Netbeans 6.8

    Read the article

  • C++ and preprocessor macro gotcha

    - by aaa
    hello. Appologies for yet another gotcha question. Can you figure out what is wrong with the statement below? gcc error states: "type name declared as function returning array". #define MACRO(a) (a)[1] class index { typedef int index_type[2]; index_type& operator[](int i); }; int k = 0; int i = MACRO(index()[k]); ps: is such questions are deemed too annoying, I am going to stop.

    Read the article

  • C++ Preprocessor Decisions

    - by PhilCK
    Sorry I know this is basic, but perhaps it doesn't exist or I'm not googling the right words is there and a if not (is that ifndef?) an AND and an OR? so I could do something like if not DEBUG and MACOS thanks

    Read the article

  • Remove extra junk from C proprocessor?

    - by Brendan Long
    I'm trying to use the C proprocessor 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

  • Trouble with __VA_ARGS__

    - by Noah Roberts
    C++ preprocessor __VA_ARGS__ number of arguments The accepted answer there doesn't work for me. I've tried with MSVC++ 10 and g++ 3.4.5. I also crunched the example down into something smaller and started trying to get some information printed out to me in the error: template < typename T > struct print; #include <boost/mpl/vector_c.hpp> #define RSEQ_N 10,9,8,7,6,5,4,3,2,1,0 #define ARG_N(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,N,...) N #define ARG_N_(...) ARG_N(__VA_ARGS__) #define XXX 5,RSEQ_N #include <iostream> int main() { print< boost::mpl::vector_c<int, ARG_N_( XXX ) > > g; // ARG_N doesn't work either. } It appears to me that the argument for ARG_N ends up being 'XXX' instead of 5,RSEQ_N and much less 5,10,...,0. The error output of g++ more specifically says that only one argument is supplied. Having trouble believing that the answer would be proposed and then accepted when it totally fails to work, so what am I doing wrong? Why is XXX being interpreted as the argument and not being expanded? In my own messing around everything works fine until I try to pass off VA_ARGS to a macro containing some names followed by ... like so: #define WTF(X,Y,...) X , Y , __VA_ARGS__ #define WOT(...) WTF(__VA_ARGS__) WOT(52,2,5,2,2) I've tried both with and without () in the various macros that take no input.

    Read the article

  • External table and preprocessor for loading LOBs

    - by David Allan
    I was using the COLUMN TRANSFORMS syntax to load LOBs into Oracle using the Oracle external which is a handy way of doing several stuff - from loading LOBs from the filesystem to having constants as fields. In OWB you can use unbound external tables to define an external table using your own arbitrary access parameters - I blogged a while back on this for doing preprocessing before it was added into OWB 11gR2. For loading LOBs using the COLUMN TRANSFORMS syntax have a read through this post on loading CLOB, BLOB or any LOB, the files to load can be specified as a field that is a filename field, the content of this file will be the LOB data. So using the example from the linked post, you can define the columns; Then define the access parameters - if you go the unbound external table route you can can put whatever you want in here (your external table get out of jail free card); This will let you read the LOB files fromn the filesystem and use the external table in a mapping. Pushing the envelope a little further I then thought about marrying together the preprocessor with the COLUMN TRANSFORMS, this would have let me have a shell script for example as the preprocessor which listed the contents of a directory and let me read the files as LOBs via an external table. Unfortunately that doesn't quote work - there is now a bug/enhancement logged, so one day maybe. So I'm afraid my blog title was a little bit of a teaser....

    Read the article

  • C# Preprocessor Directives

    - by MarkPearl
    Going back to my old c++ days at university where we had all our code littered with preprocessor directives - I thought it made the code ugly and could never understand why it was useful. Today though I found a use in my C# application. The scenario – I had made various security levels in my application and tied my XAML to the levels by set by static accessors in code. An example of my XAML code for a Combobox to be enabled would be as follows… <ComboBox IsEnabled="{x:Static security:Security.SecurityCanEditDebtor}" />   And then I would have a static method like this… public static bool SecurityCanEditDebtorPostalAddress { get { if (SecurityCanEditDebtorPostalAddress) { return true; } else { return false; } } } My only problem was that my XAML did not like the if statement – which meant that while my code worked during runtime, during design time in VS2010 it gave some horrible error like… NullReferenceException was thrown on “StatiucExtension”: Exception has been thrown by the target of an invocation… If however my C# method was changed to something like this… public static bool SecurityCanEditDebtorPostalAddress { get { return true; } }   My XAML viewer would be happy. But of course this would bypass my security… <Drum Roll> Welcome preprocessor directives… what I wanted was during my design experience to totally remove the “if” code so that my accessor would return true and not have any if statements, but when I release my project to the big open world, I want the code to have the is statement. With a bit of searching I found the relevant MSDN sample and my code now looks like this… public static bool SecurityCanEditDebtorPostalAddress { get { #if DEBUG return true; #else if (Settings.GetInstance().CurrentUser.SecurityCanEditDebtorPostalAddress) { return true; } else { return false; } #endif } }   Not the prettiest beast, but it works. Basically what is being said here is that during my debug mode compile my code with just the code between the #if … #else block, but what I can now do is if I want to universally switch everything to the “if else” statement, I just go to my project properties –> Build and change the “Debug” flag as illustrated in the picture below. Also note that you can define your own conditional compilation symbols, and if you even wanted to you could skip the whole properties page and define them in code using the #define & #undef directives. So while I don’t like the way the code works and would like to look more into AOP and compare it to this method, it works for now.

    Read the article

  • What is the worst real-world macros/pre-processor abuse you've ever come across?

    - by Trevor Boyd Smith
    What is the worst real-world macros/pre-processor abuse you've ever come across (please no contrived IOCCC answers *haha*)? Please add a short snippet or story if it is really entertaining. The goal is to teach something instead of always telling people "never use macros". p.s.: I've used macros before... but usually I get rid of them eventually when I have a "real" solution (even if the real solution is inlined so it becomes similar to a macro). Bonus: Give an example where the macro was really was better than a not-macro solution. Related question: When are C++ macros beneficial?

    Read the article

  • What does #error do?

    - by cambr
    I am guessing from # that it is only a compile-time utility. How can it be used in C/C++ programs? Did not find much about it on the internet. Any links would be helpful.

    Read the article

  • C/GCC - Is it possible to sort arrays using preprocessor?

    - by psihodelia
    I have a number of very long arrays. No run-time sort is possible. It is also time consuming to sort them manually. Moreover, new elements can be added in any order later, so I would like to sort them by value using C preprocessor or maybe there is any compilers flag (GCC)? For example: sometype S[] = { {somevals, "BOB", someothervals}, {somevals, "ALICE", someothervals}, {somevals, "TIM", someothervals}, } must be sorted so: sometype S[] = { {somevals, "ALICE", someothervals}, {somevals, "BOB", someothervals}, {somevals, "TIM", someothervals}, }

    Read the article

  • Using C preprocessor to construct a string literal for scanf?

    - by Brett
    I'm attempting to create an sscanf string literal to aid in buffer overrun prevention in C99. The goal is something like: #define MAX_ARG_LEN 16 char arg[MAX_ARG_LEN] = ""; if (sscanf(arg, "%"(MAX_ARG_LEN-1)"X", &input) > 0) The obvious "manual" solution is something like: #define MAX_ARG_LEN 16 #define MAX_ARG_CHARS "15" char arg[MAX_ARG_LEN] = ""; if (sscanf(arg, "%"MAX_ARG_CHARS"X", &input) > 0) However, I would prefer something to automatically generate "%15X" given a buffer size of 16. This link is almost works for my application: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string but it does not handle the -1. Suggestions?

    Read the article

  • Why is this C or C++ macro not expanded by the preprocessor?

    - by Atul
    Can someone points me the problem in the code when compiled with gcc 4.1.0. #define X 10 int main() { double a = 1e-X; return 0; } I am getting error:Exponent has no digits. When i replace X with 10, it works fine. Also i checked with g++ -E command to see the file with preprocessors applied, it has not replaced X with 10. I was under the impression that preprocessor replaces every macro defined in the file with the replacement text with applying any intelligence. Am I wrong? I know this is a really silly question but I am confused and I would rather be silly than confused :). Any comments/suggestions.

    Read the article

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