The tag has no wiki summary.

learn more… | top users | synonyms

4
votes
1answer
48 views

C++: Generating similar methods with macros

I am currently working on a project that involves Lua. For convenience, I created a wrapper class for the Lua state structure. However, I also added some methods for getting globals and table fields. ...
2
votes
2answers
172 views

C try/catch macros

I've created simple try/catch macros that now I'd like to promote to wider use in my projects. I would have really liked to be able to do without global variables but I have not found any way to do ...
2
votes
2answers
64 views

A defined macro to copy selected values of std::vector to an array using std::copy

Thought I share this piece of code to the world. But be aware, I am not sure if this piece of code is safe and efficient. Feel free to improve it or give some feedback and suggestions. #pragma region ...
2
votes
1answer
68 views

Simplify complex hash-table manipulations in Common Lisp

I'm trying to write a simple triplestore in Common Lisp that will store triples in the form subject-predicate-object. The code is inspired by the book "Programming the Semantic Web". (defvar ...
4
votes
2answers
167 views

Is this C game code OK? Structures and bitfield flags with some macros to handle them

I wrote some C code for working with some data for a game, I wanted to know what do you think and what could I do to improve it, what should I change, etc. These are just some lines of the file, you ...
3
votes
1answer
241 views

Qt foreach-like alternative to iterate over value AND key of an associative container

The Qt documentation recommend an iterator-based solution to iterate over an associative container like QMap and QHash, and I always wondered if there really isn't a (nice) solution using a foreach ...
1
vote
2answers
101 views

with-alist-bind

Take 4 (alteration based on feedback from Rainer Joswig): (defmacro with-gensyms ((&rest names) &body body) `(let ,(loop for n in names collect `(,n (gensym))) ,@body)) (defmacro ...
1
vote
2answers
629 views

Objective-C debug macros

I'm looking for a review of my macros. I have these in the project pre-compile header. I tent to copy them into all my new projects as well, unless its a very simple project. #ifdef __APPLE__ ...
4
votes
2answers
290 views

Solving the problem of using directives in a header file with a macro. Is this stupid?

I am writing some library code that is mostly templates and so is all contained in header files. I know that placing a using declaration in a header will pollute all the files that include it, but I'm ...
6
votes
5answers
694 views

Run once macro, how bad idea?

I'm using this little macro a lot: #define RUN_ONCE(runcode) \ { \ static bool code_ran = 0; \ if(!code_ran){ \ code_ran = 1; \ runcode; \ } \ } I find it useful when i ...
2
votes
1answer
82 views

Keys in mode maps

I noticed a pattern in some elisp modes I was putting together: (let ((map (make-sparse-keymap))) (define-key map KEY 'FN) ... (setq FOO map)) so I wrote up the following macro (defmacro ...
7
votes
4answers
1k views

'do { statement; } while(0)' against 'statement' when writing C macro?

Which one of the following is preferrable and why when writing C macro? Type 1 #define I2C_START() I2C_WAIT_IDLE(); SSP1CON2bits.SEN = 1 Type 2 #define I2C_START() ...
2
votes
1answer
157 views

Is this a good way to implement let-with?

I've implemented a let-with macro that takes an association list, keyed by symbols, that enables code to bind their corresponding values to local variables. It's designed to have a similar effect to ...