×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    typename redefined problems

    hi,

    i get "typename redefined" errors quite a bit in my current project. basically my project doesn't compile at the moment and it would seem to be a compiler problem. of course I have

    #ifndef x
    #define x
    <header file>
    #endif

    around each header file, but on the class definition line in the header file I get a single error saying "typename redefined". this happens for some of my classes and not others. i use a very OO methodology so there's abstract classes to a couple of levels but i can't work out the pattern of why the compiler spits at some classes and not others.

    any ideas anyone? anyone had the same sort of problems?

    it's getting pretty urgent. i'm thinking of downloading Carbide.c++ v1.1 anyway but i want to know if this is something to do with the underlying compiler or whatever.

    cheers!
    matt

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: typename redefined problems

    Some more details could be handy (class names, class declaration heads, etc.).

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    Re: typename redefined problems

    Hi!

    It's a rather complex setup so I was just hoping there might have been a known issue or something. Anyway, I appreciate your time.. here goes!

    First thing that I want to mention is the structure of my project. It's setup up so that I've got common source folders in one location and they are compiled into different platform binaries using linked folders.

    The directories with (c) are "Source Code" directories in Carbide and the ones marked with (L) are linked to file system directories which can be anywhere on the file system (so that I can maintain them separate to the Symbian projects:

    <Project>
    |- Includes
    | |- <project>/inc
    | |- <project>/Common/Core/inc
    | |- <project>/SymbianOSCommon/Core/inc
    | - Src(c)
    | - Inc(c)
    | - Sis(c)
    | - Common(c)(L)
    | |- Core
    | | |- inc
    | | |- src
    | |- ComponentX
    | | |- inc
    | | |- src
    | - SymbianOSCommon(c)(L)
    | |- Core
    | | |- inc
    | | |- src
    | |- ComponentX
    | | |- inc
    | | |- src
    .... etc etc

    So I don't know if having the "include" directories under a source code directory as well as in the includes is a problem, but I can't see how it would be.

    Here's a couple of classes which get the "typename redefined" error:

    -- SHttpInterfaceObserver.h --
    #ifndef SHTTPINTERFACEOBSERVER_H_
    #define SHTTPINTERFACEOBSERVER_H_

    #include "SHttpInterface.h"
    #include "SError.h"
    #include "SmartPtr.h"

    class SHttpInterfaceObserver { // "typename redefined" error here!
    public:
    virtual void httpInterfaceResult(SPtr<SHttpInterface> interface) = 0;
    virtual void httpInterfaceError(SError error, SPtr<SHttpInterface> interface) = 0;
    };

    #endif /*SHTTPINTERFACEOBSERVER_H_*/
    --

    -- SFileSystemInterface.h --
    #ifndef SFILESYSTEMINTERFACE_H_
    #define SFILESYSTEMINTERFACE_H_

    #include "SFileName.h"
    #include "QString.h"
    #include "SmartPtr.h"
    #include "Vector.h"
    #include "Platform.h"

    class SFileSystemInterface { // "typename redefined" error here!
    public:
    virtual SPtr<QString> getAppDataDir() = 0;
    virtual SPtr<QChar> getDirSeparatorChar() = 0;

    // generic entry functions
    virtual bool exists(SPtr<SFileName> entry) = 0;
    virtual void copyEntry(SPtr<SFileName> entry, SPtr<SFileName> newEntry) = 0;
    virtual void deleteEntry(SPtr<SFileName> entry) = 0;
    virtual void renameEntry(SPtr<SFileName> entry, SPtr<SFileName> newEntry) = 0;
    virtual void touchEntry(SPtr<SFileName> entry) = 0;

    // directory functions
    virtual void createDirectory(SPtr<SFileName> dir) = 0;
    virtual bool isDirectory(SPtr<SFileName> entry) = 0;
    virtual Vector< SPtr<SFileName> > listContents(SPtr<SFileName> dir) = 0;

    // file functions
    virtual bool isOpen(SPtr<SFileName> file) = 0;
    virtual UINT32 size(SPtr<SFileName> file) = 0;
    };

    #endif /*SFILESYSTEMINTERFACE_H_*/
    --

    -- SFileName.h --
    #ifndef SFILENAME_H_
    #define SFILENAME_H_

    #include "SFileSystemInterface.h"
    #include "SmartPtr.h"
    #include "QString.h"

    class SFileName {
    public:
    inline SFileName(SPtr<SFileSystemInterface> fs) {};
    inline virtual ~SFileName() {};

    virtual void setFilename(SPtr<QString> path, SPtr<QString> name);
    virtual void setFilename(SPtr<QString> fullName);

    virtual void pushNameElement(SPtr<QString> name);
    virtual SPtr<QString> popNameElement();

    virtual SPtr<QString> getFullName();
    virtual SPtr<QString> getPath();
    virtual SPtr<QString> getName();

    private:
    SPtr<SFileSystemInterface> fs;
    SPtr<QString> fileName;
    };

    #endif /*SFILENAME_H_*/
    --

  4. #4
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: typename redefined problems

    Could you please also post your SHttpInterface.h
    Regards,
    ivey

  5. #5
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: typename redefined problems

    Quote Originally Posted by matpowel
    Hi!



    class SHttpInterfaceObserver { // "typename redefined" error here!

    class SFileSystemInterface { // "typename redefined" error here!

    class SFileName {

    Class Name Conventions on Symbian OS

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    Re: typename redefined problems

    Thanks for your time!

    There is one error in this file where it says "ERROR ON THIS LINE"

    -- SHttpInterface.h --
    #ifndef SHTTPINTERFACE_H
    #define SHTTPINTERFACE_H

    #include "SHttpDataInterface.h"
    #include "SHttpInterfaceObserver.h"
    #include "SHttpResult.h"
    #include "SmartPtr.h"
    #include "Vector.h"
    #include "QString.h"

    class SHttpInterface : public SHttpDataInterface {
    public:
    virtual void setObserver(SPtr<SHttpInterfaceObserver> observer) = 0; // ERROR ON THIS LINE: Undefined identifier "SHttpInterfaceObserver"

    virtual void post(SPtr<QString> url, SPtr<SHttpDataInterface> poster) = 0;
    virtual void get(SPtr<QString> url) = 0;

    virtual SPtr<SHttpResult> getResult() = 0;
    };

    #endif /*SHTTPINTERFACE_H*/
    --

  7. #7
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    Re: typename redefined problems

    Quote Originally Posted by vin2ktalks
    Yeah I know it inside and out, I've been developing for Symbian for about 5 years including 3 years at Nokia. The codebase in this project is multi-platform. Meaning Microsloth Mobile, Symbian OS, Palm OS etc etc. The coding conventions transcend the platform. There's some rhyme and reason to it.

    Just to be confusing, the Symbian OS portions of the code will use the Symbian OS conventions. Don't ask, it just is :-)

    Matt

  8. #8
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: typename redefined problems

    Your code does not compile because SHttpInterface.h includes SHttpInterfaceObserver.h and SHttpInterfaceObserver.h includes SHttpInterface.h.

    Maybe it is acceptable for you to use SHttpInterface* as the SPtr template argument. In this case you can predefine SHttpInterface and do not include SHttpInterface.h in SHttpInterfaceObserver.h.
    Regards,
    ivey

  9. #9
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    Re: typename redefined problems

    Oh, you are right. Thanks! It compiles fine now. That saved me some hassle. I've been mostly coding only Java for the last year so maybe my head is just not back into the C++ which was always my thing.. but this is different to the VC++ compiler isn't it? I have always worked in MSVC up until now.

    I mean, it would actually seem like a compiler bug.

    Surely if the compiler does this:
    - #define's SHTTPINTERFACE_H
    - then expands the #include SHttpInterfaceObserver.h directive
    - #define's SHTTPINTERFACEOBSERVER_H
    - then expands the #include SHttpInterface.h directive
    then it shouldn't get past the #ifdef SHTTPINTERFACE_H.. surely? Perhaps the compiler expands the #include's in the same pass as the #defines? That would seem pretty silly.

    Getting back into the C++ world with an entirely new SCM (Subversion), IDE (Carbide.c++) and picking up a new OS (Palm) all at once has been a world of fun... not.

    Thanks for your patience!

    Matt

  10. #10
    Registered User
    Join Date
    Aug 2009
    Posts
    25

    Re: typename redefined problems

    I have 2 files which are interdependent as mentioned in the above hread.

    I need to have such functionality and I am not able to find the other way around.

    For Ex:
    ---------
    A* foo1;
    B* foo2;

    foo1->child = B;
    foo2->parent = A;

    So I need to have such kind of interlinking.

    But if I #include "A.h" in B.h and "B.h" in A.h, I am getting this error.

    Someone please suggest an alternative how to achieve this functionality.

    Thanks in Advance

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: typename redefined problems

    That is a use case for forward declarations: http://discussion.forum.nokia.com/fo...d.php?t=158666

Similar Threads

  1. typename redefined error
    By sunny_singh in forum Symbian
    Replies: 1
    Last Post: 2006-09-18, 04:20
  2. Several problems with NMIT 4.1 MMS
    By jtalviva in forum General Messaging
    Replies: 0
    Last Post: 2006-03-10, 11:03
  3. Several problems with NMIT 4.1
    By jtalviva in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-03-10, 10:59
  4. Problems with Nokia carkit CK-1W
    By Batunas in forum General Development Questions
    Replies: 1
    Last Post: 2004-02-09, 18:18

Posting Permissions

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