Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Help!! Got compilation error in FC 4, but it was OK in FC2

    Sorry I am new to Linux, please help.

    I created a small project by using KDeveloper in FC2. It worked fine. But when I did the same thing in FC4, unless I change "m_x = 3" to "John<T>::m_x = 3", gcc 4.0.0 always give me a fatal error --- "error: m_x was not declared in this scope".

    #ifdef HAVE_CONFIG_H
    #include <config.h>

    #include <iostream>
    #include <cstdlib>

    using namespace std;

    template <class T>
    class John
    int m_x;

    template <class T>
    class Johnsonublic John <T>
    void dothis();

    template <class T>
    void Johnson<T>::dothis()
    m_x = 3;
    cout << "x=" << m_x;

    int main(int argc, char *argv[])
    cout << "Hello, world!" << endl;

    Johnson<int> johnson1;

    return EXIT_SUCCESS;

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    St. Petersburg, FL
    It would seem that gcc4 has stricter rules when it comes to scope...I don't think there's much you can do about it...Is it simply a warning or a fatal error that aborts compilation?

  3. #3
    Thanks for the help.

    It is a fatal error ----- error: m_x was not declared in this scope

  4. $spacer_open

Posting Permissions

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