Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  do {...} while (0) in macros

If you are a C programmer, you must be familiar with macros. They are powerful and can help you ease your work if used correctly. However, if you don't define macros carefully, they may bite you and drive you crazy. In many C programs, you may see a special macro definition which may seem not so straightforward. Here is one example:#define __set_task_state(tsk, state_value) \ do { (tsk)->state = (state_value); } while (0)There are many this kind of macros which uses do{...}while(0) in Linux kernels and other popular C libraries. What's the use of this macro? Robert Love from Google(...

139,363 14       C C++ MACRO


  Office 2013 RT for Windows RT tablets may rule out macros and VBA

Office 2013 RT is the office suite optimized for Windows RT system running on ARM tablet PC, Microsoft plans to release a preview version later this year. However, according to TheVerge, Microsoft may remove some features in this version of the Office suite.The so-called optimization, certainly require some changes to Office based on ARM tablet architecture. To remove some features may be because of battery life and machine reliability considerations. Macrso, third-party add-ons, and VBA will be ruled out from Office 2013 RT. Some other features may also be removed.A Microsoft spokesman said t...

4,495 0       MACRO OFFICE 2013 WINDOW RT


  Macro to change text color conditionally in Excel

Macros are small but very powerful VBA programs in Microsoft Office software. They can help us complete some repeated tasks automatically. Today, I will show you one macro example which is to change the text color conditionally. The excel file has a work sheet which contains some records of request. I want to check the status of each request, if the status of a request is approved, the text color of the status should be green; if the status of a request is rejected, the text color of the status should be red; otherwise the text color of the status should be black. Here is the code for the mac...

38,955 2       EXCEL MACRO TEXT COLOR CONDITIONALLY


  C Macro Tips and Tricks

Preprocessor vs CompilerTo properly understand C macros, you must understand how a C program is compiled. In particular, you must understand the different things that happen in the preprocessor and in the compiler.The preprocessor runs first, as the name implies. It performs some simple textual manipulations, such as:Stripping comments. Resolving #include directives and replacing them with the contents of the included file. Evaluating #if and #ifdef directives. Evaluating #defines. Expading the macros found in the rest of the code according to those #defines.It is, of course, these...

18,308 0       C MACRO PREPROCESSOR TRICK


  Lisp: It's Not About Macros, It's About Read

Note: the examples here only work with outlet lisp. Refer to your version of lisp/scheme’s documentation for how read works (and possibly other forms)I know it’s an old post by now, but something about the article Why I love Common Lisp and hate Java, part II rubbed me the wrong way. The examples just aren’t that good. The usage of macros is plain baffling, when a function would have been fine. The author admits this, but still does it. There’s a follow-up post which focuses more on macros but it still misses the point.Here’s the thing: it’s not really...

5,501 0       JAVA MACRO LISP READ


  Vim anti-patterns

The benefits of getting to grips with Vim are immense in terms of editing speed and maintaining your “flow” when you’re on a roll, whether writing code, poetry, or prose, but because the learning curve is so steep for a text editor, it’s very easy to retain habits from your time learning the editor that stick with you well into mastery. Because Vim makes you so fast and fluent, it’s especially hard to root these out because you might not even notice them, but it’s worth it. Here I’ll list some of the more common ones.Moving one line at a timeIf ...

3,116 0       VIM MACRO SYNTAX ANTI-PATTERN


  Scala Macros

This is the home page of project Kepler, an ongoing effort towards bringing compile-time metaprogramming to Scala. Our flavor of macros is reminiscent of Lisp macros, adapted to incorporate type safety and rich syntax. Unlike infamous C/C++ preprocessor macros, Scala macros: 1) are written in full-fledged Scala, 2) work with expression trees, not with raw strings, 3) cannot change syntax of Scala. You can learn more about our vision of metaprogramming from our talks. We propose to enrich Scala programming language with three flavors of type-safe compile-time macros: macro defs, macro types and...

6,616 0       SCALA EFFICIENCY MACRO MAINTAINEBILITY


  Macro vs. Micro Optimisation

So there's recently been a bit of hype about another Colebourne article: http://blog.joda.org/2011/11/real-life-scala-feedback-from-yammer.htmlI'd like to respond to a few points he makes.First - You should evaluate Scala and pay attention to its benefits and flaws before adopting it.  Yes, there are flaws to Scala.   Working at typesafe makes you more aware of some of them.  We're actively working to reduce/minimize/get rid of these.   In my opinion, the negatives of using Scala are peanuts compared to the postives of choosing Scala over Java.  I think everyone s...

2,843 0       SOFTWARE PERFORMANCE OPTIMIZATION MACRO MICRO