Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: How to generate single C++ header and code files from several files

  1. #1
    Senior Member
    Join Date
    May 2018
    Posts
    131

    How to generate single C++ header and code files from several files

    Hi,

    sorry, this is more of a general C++ topic, but my question is aimed at a Teensy project. So I hope it's ok if I ask the question here.

    I am developing MicroDexed, a 6 OP FM synth (compatible with a famous synth from the 80ies). The sound generation code is taken from Dexed (a JUCE based implementation of the msfa engine). It's working fine.

    But now I thought about to build a single audio object for Teensy. The current audio engine code is stable and is very rarely touched. Currently the code is splitted over several *.h and *.cpp files. My idea was to put the engine code into a single *.cpp and *.h file. But how to do this?

    Simply merging the files will probably not work. Does anyone have an idea how to do this?

    TIA, Holger

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    905
    Can you explain why this would be advantageous to you?

  3. #3
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    264
    If they are poper c++ files
    Using classes the merge should be possible without any issues, however if there is non classed functions with the same names in the CPP files then you get conflicts.

  4. #4
    Senior Member
    Join Date
    May 2018
    Posts
    131
    Quote Originally Posted by MarkT View Post
    Can you explain why this would be advantageous to you?
    The handling for me would be easier (in Arduino IDE) - not so much files.

    But the main reason is that I can use it like a Teensy-Audio-Library object (e.g. as synth_dexed()). So others can use this object simply by adding the class and header file.

  5. #5
    Senior Member
    Join Date
    May 2018
    Posts
    131
    Quote Originally Posted by manicksan View Post
    If they are poper c++ files
    Using classes the merge should be possible without any issues, however if there is non classed functions with the same names in the CPP files then you get conflicts.
    There are mainly classes. But it seems that there are nearly no conflicting function names if not class based.

    I found a way by using https://github.com/dwd31415/single-c-file for the headers and cpp files. There were some small conflicts I had to resolve but now the compiler does not complain anymore... But I currently don't know if it works - I have to write some test code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •