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 6761099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:08:45+00:00 2026-05-26T14:08:45+00:00

I’m currently running a c++ project, with a class called Relation. I’m trying to

  • 0

I’m currently running a c++ project, with a class called Relation.

I’m trying to compile it, but I constantly get this error, regardless of the file extension that I’m using.

Compiler is cc, and the class I’m trying to compile, even when empty as below, causes this error.

I’ve tried the c++ header extensions, and the same errors occur.

#ifndef RELATION_H_
#define RELATION_H_

class Relation {
public:
Relation();
virtual ~Relation();
};

#endif
  • 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-26T14:08:45+00:00Added an answer on May 26, 2026 at 2:08 pm

    That’s the error you get when you try to compile C++ code with the C compiler.

    pax$ cat qq.cpp
    class Relation {
    public:
        Relation();
        virtual ~Relation();
    };
    
    pax$ g++ -c -o qq.o qq.cpp
    
    pax$ cp qq.cpp qq.c
    
    pax$ gcc -c -o qq.o qq.c
    qq.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Relation'
    

    You should check that your cc compiler is actually capable of compiling C++ and what, if any, options are needed to make it do so.

    If it’s gcc (and it certainly looks like it is, based on the absolutely identical error message), you may need to make sure that you’re calling g++ rather than gcc and/or that your extension for the source file (not header) is a recognised one, like .cpp (a).

    I’m not entirely certain the rules that gcc follows but I’ve always found it safer to use source files like blahblah.cpp and explicitly use g++.


    (a) Reasoning: since you mention in your particular case that you’re using the correct header file extensions, I think one possibility is that the header extension has no effect whatsoever on what gcc tries to compile the source file as. It uses only the source file extension, as per the following transcript:

    pax$ cat xyzzy.hpp
    class Relation {
    public:
        Relation();
        virtual ~Relation();
    };
    
    pax$ cat plugh.c
    #include "xyzzy.hpp"
    
    pax$ gcc -c -o plugh.o plugh.c
    In file included from plugh.c:1:
    xyzzy.hpp:1: error: expected '=', ',', ';', 'asm' or '__attribute__'
                        before 'Relation'
    
    pax$ cp plugh.c plugh.cpp
    
    pax$ gcc -c -o plugh.o plugh.cpp
    

    In other words, I don’t think having an included header file of (for example) xyzzy.hpp would force the compiler to compile C++ if the source file that’s including it is still plugh.c.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.