CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Converting C To C++ - It Worked In Original C But Not In Converted C++?

  1. #1
    Join Date
    May 2020
    Posts
    1

    Question Converting C To C++ - It Worked In Original C But Not In Converted C++?

    Hi,

    Doing some audio work with SDL2.
    Trying to get multi-channel audio to work with just SDL2.

    We found below working example:
    https://github.com/jakebesworth/Simple-SDL2-Audio
    but it is in C so we tried to convert it to C++.

    Current version of our SDL2 project is live on GitHub below:
    https://github.com/FallenAngelSoftware/SDL2-C64GKGM2

    Our SDL2 project builds and runs with 0 errors and 0 warnings, just no audio plays?
    Any help would be appreciated, thank you!

    Jesse

  2. #2
    Join Date
    Feb 2017
    Posts
    536

    Re: Converting C To C++ - It Worked In Original C But Not In Converted C++?

    The program design principle of Stepwise Refinement is useful also for porting:

    1. First strip down the C version to a working bare minimum, typically just a few lines of code.

    2. Then port it to a C++ environment and make sure it works.

    3. Add on more C code to the C++ environment in small incremental steps and make sure each step works.

    4. When all C code is in the C++ environment you have a complete working C++ port of the original C code.
    Last edited by wolle; May 4th, 2020 at 11:51 AM.

  3. #3
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,118

    Re: Converting C To C++ - It Worked In Original C But Not In Converted C++?

    Nobody here is going to debug your c++ code for you - or do a code comparison between the c & c++ versions.

    What debugging have you done? As the audio is being produced by SDL2, have you logged all the calls to SDL2 in the c version and the c++ version? What are the differences? This will give you a clue as to a possible issue with the C++ version.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.6.1)

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)