Giter VIP home page Giter VIP logo

cch's Introduction

CCH

CCH is a C++ preprocessor that removes the need to manually separate function declarations and implementation. C++ code can be written in a single .cch file and CCH will automatically split it into corresponding .cc and .h files. Keep build times, header size, and editor window switches to a minimum.

CCH is designed to be hooked into your build system as a step prior to compilation and offers numerous usages to fit any build system.

CCH emits #line directives so all line-number-dependent constructs (e.g. compiler errors, logging systems) are true to the original .cch file.

Try CCH and see what it can do for your C++ codebase today!

Consider trying makefile.py as well - autogenerate a Makefile for your project.

Build Status

Installation

For both Linux and OS X:

make && make test && sudo make install

For Windows compilation under Cygwin:

make && make test

then copy the binary to some directory in PATH.

For configuring your editor, see editor bindings below.

Example

.cch file:
#include <vector>

class foo : public bar {
  static const int shift = 2;
  int x;
public:
  foo(int a)
    : x(a>>shift) {}

  int compute(int a, int b) {
    for (int i = 0; i < 32; i++) {
      if (a & 0b1) {
        b++;
      }
    }
    return b * x;
  }
};
Generated .h:
#ifndef __readme_readme_cch__
#define __readme_readme_cch__
#include <vector>

class foo : public bar {
  static const int shift;
  int x;
public:
  foo(int a);

  int compute(int a, int b);
};

#endif
Generated .cc:
#include "readme/readme.cch.h"

  /* static */ const int foo::shift = 2;
  foo::foo(int a)
    : x(a>>shift) {}

  int foo::compute(int a, int b) {
    for (int i = 0; i < 32; i++) {
      if (a & 0b1) {
        b++;
      }
    }
    return b * x;
  }

Editor bindings

The following are handy shortcuts to have .cch files handled as C++ code in your favorite editors:

emacs - add the following to your .emacs:

(setq auto-mode-alist
    (cons '("\\.cch$" . c++-mode) auto-mode-alist))

vim - add the following to your .vimrc:

au BufEnter *.cch setf cpp

ctags - add .cch to the extension->language mapping when invoking ctags:

$ ctags ... --langmap="c++:+.cch" ...

cch's People

Contributors

tjps avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

benguang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.