Sunday, April 3, 2011

C++ Header To Source?

Hi, I'm programming in C++ CLI with VS.Net C++ 2008. I'm seeking a tool that can create my C++ source definitions (*.cpp) from the header files. Does such a tool exist? please advise, thanks.

From stackoverflow
  • I'm seeking a tool that can create my C++ source definitions (*.cpp) from the header files.

    Do you mean: How do I copy the function signatures? Because, I wouldn't want a program to define any functions for me. Who want's to lose a job now ;)

    Anyway, you can define your own macro for the IDE if you want to copy signatures.

  • Code::Blocks IDE seems to have a "Insert / All class methods without Implementation" method which generates some basic skeleton of the functions.

  • For pure C++ code, if its possible to add a 3rd party generator to the VS.Net frame work, then I would strongly recommend: lzz.

    This tools takes a text file as input, and will provide a header and source file for you as appropriate. The following is the basic example from the web page:

    // A.lzz
    class A
    {
    public:
      inline void f (int i) { ... }
      void g (int j = 0) { ... }
    };
    bool operator == (A const & a1, A const & a2) { ... }
    

    Lzz will generate a header file:

    // A.h
    #ifndef LZZ_A_h
    #define LZZ_A_h
    class A
    {
    public:
      void f (int i);
      void g (int j = 0);
    };
    inline void A::f (int i) { ... }
    bool operator == (A const & a1, A const & a2);
    #endif
    

    And a source file:

    // A.cpp
    #include "A.h"
    void A::g (int j) { ... }
    bool operator == (A const & a1, A const & a2) { ... }
    

0 comments:

Post a Comment