ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Expand​CMacro

by pl-ca OS XLinux ST2/ST3

Sublime Text 3 plugin that expands C/C++ macros.

Labels Expand, Macro, Expansion, C, C++

Details

Installs

  • Total 100
  • Win 0
  • OS X 35
  • Linux 65
Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OS X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Linux 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

ExpandCMacro

Sublime Text 3 plugin that expands C/C++ macros. Currently only works on Linux/OS X

Example

#include <stdio.h>


#define PRINT_2(MSG, ARGS...) printf(MSG, ##ARGS);
#define PRINT(MSG,ARGS...) PRINT_2(MSG,##ARGS)
#define MACRO(X)                                              \
{                                                             \
    if (1)                                                    \
        PRINT("this is a test %d\n", X)                       \
    else                                                      \
        PRINT("---- %s -----\n", "this is another test")      \
}

int main()
{
    MACRO(25)
    return 0;
}

Executing the command on the line MACRO(25) will result in following output

{ if (1) printf("this is a test %d\n", 25); else printf("---- %s -----\n", "this is another test"); }`

Installation

  1. Install “clang” or “gcc”.
  2. Clone this repository and put it in your Sublime's packages directory (only if installing manually from GitHub).
  3. Edit the settings to your needs.
  4. Default key bindings are: “ctrl-alt-z” to put result output panel.
  5. To modify those bindings, simply edit “Default (OSX).sublime-keymap” or its linux counterpart.

Settings

  • include_dirs: List of directories where relevant header files are located
  • compiler: Use gcc or clang to get result
  • other_flags: You can define compile time macros here with “-D DEFINE_SOMETHING”