Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6214097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:48:59+00:00 2026-05-24T06:48:59+00:00

Note: I am using g++ version 4.3.4 to compile my C++ code. So far,

  • 0

Note: I am using g++ version 4.3.4 to compile my C++ code.

So far, whenever I’ve wanted to use C style language elements in my code it seems that I can just include the C stuff mixed in and alongside my C++.

I know C++ is mostly backwards compatible with C… so I guess my questions are these:

What parts of C are not forwards compatible with C++?

Will professional programmers laugh at me if I continue to naively stick C stuff into my C++ code?

What is the proper way to have C and C++ code in the same .cpp file?

Can I continue to use g++ to compile my hybrid code?

For this question, I am mostly concerned with a solution that deals with a single .cpp file and a single g++ command to compile it. I don’t really care about linking stuff at this point.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:48:59+00:00Added an answer on May 24, 2026 at 6:48 am

    Picking out a couple of questions:

    “What is the proper way to have C and C++ code in the same .cpp file?”
    “Can I continue to use g++ to compile my hybrid code?”

    If you want to mix C-style C++ in the same file as regular C++, just go ahead and do it. You can trust the compiler to pick up any issues – they will be minimal and not affect the structure. By the sound of it, you are not interested in getting C-linkage for its own sake, so even if the C-Code is in its own file, compile it as C++. As a matter of fact this is often done as a way of migrating from C to C++.

    If you take this approach, your code is not truly hybrid C/C++. It is C++ with some of the code using C-style procedural idioms. C++ is fully intended to support this.

    “Will professional programmers laugh at me if I continue to naively stick C stuff into my C++ code?”

    It depends where you are using it and why. Well structured C code is good code. Sometimes C+ is much better than C at particular problems. Think hard before using C-style dynamic memory management. You will deserved to be laughed at if you use raw malloc()/free() and get it wrong.

    I suggest that if you embark on this approach, you might later take the time to look back and consider whether or not you would have been better to use C++ idioms instread of procedural C.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found the following claim in the documentation for Net::OpenSSH : Note that using
This code fails to compile using g++ 4.2.1 but works fine under vc++ v8.
I'm using ant to build a mixture of Java and C++ (JNI) code that
I'm trying to use the std::shared_ptr in clang++(clang version 3.1 (trunk 143100)) using libstdc++(4.6.1).
Can one of you explain why the following piece of code does not compile?
I've got some code that I've been using successfully for some years to implement
I am using VS 2008 to compile and debug my code. In my application,
First things first, I'm using cygwin version 1.7.1 on a Windows 7 box. Code
In the following code, initialize() illustrates a method based on compile-time polymorphism. The version
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.