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

  • SEARCH
  • Home
  • 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 8125869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:57:40+00:00 2026-06-06T06:57:40+00:00

When compiling a c file that uses old style function definition like int foo(a)

  • 0

When compiling a c file that uses old style function definition like

int foo(a)
   int a;
{
  ...
}

g++ will give and error: ‘a’ was not declared in this scope.
gcc can parse this.
Is there a way to let g++ recognize this?

This comes up as an issue to me because I’m compiling a mix of c and c++ files.
A related question is what’s the standard practice
of building this type of mixed source? Running g++ on all files or only the cc files? The former is convenient but keeps getting me some trouble because of the inconsistencies between c and c++ specification(for example, char[4]=”four”;)

  • 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-06-06T06:57:42+00:00Added an answer on June 6, 2026 at 6:57 am

    Is there a way to let g++ recognize this?

    This syntax is not supported in C++.

    Running g++ on all files or only the cc files?

    See e.g. Compiling C++ programs from the GCC docs:

    C++ source files conventionally use one of the suffixes .C’, .cc, .cpp, .CPP, .c++, .cp, or .cxx; C++ header files often use .hh, .hpp, .H, or (for shared template code) .tcc; and preprocessed C++ files use the suffix .ii. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).

    However, the use of gcc does not add the C++ library. g++ is a program that calls GCC and treats .c, .h and .i files as C++ source files instead of C source files unless -x is used, and automatically specifies linking against the C++ library. This program is also useful when precompiling a C header file with a .h extension for use in C++ compilations.

    So two possibilities:

    1. Run gcc on C files, and g++ on C++ files.
    2. Run gcc on all files.

    In both cases you will need to link with g++ (or gcc -lstdc++).

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

Sidebar

Related Questions

Compiling a file that uses OpenGL with Visual C++, when I try to include
Recently, a coworker pointed out to me that compiling everything into a single file
I'm compiling an .as file using fcsh, which uses it mxmlc. I use the
I'm getting errors while compiling a program that uses threads. Here is the part
Anyone manage to write code that uses the mysqlclient library? I can get compiling
For some reason I have having an issue compiling a shared object that uses
I have a program that uses _mm_crc32_u64 . I include the header file smmintrin.h
I am compiling a YACC file using Cygwin shell on a PC. I am
I am compiling a latex file on a server and download from there the
Does enabling the configuration option with-config-file-scan-dir when compiling PHP lead to performance issues? Specifically,

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.