Menu

#23 C++ generator : Infinity loop with circular dependency

None
closed
nobody
None
1
2021-12-27
2014-06-01
No

Dear,

C++ generator do not detect circular dependencies (exemple enclosed). The great thing is the generator write :

FILE 1 :

ifndef CLASSE1_H

define CLASSE1_H

include "Classe2.h"

class Classe2 {} // TO AVOID CIRCULAR DEPENDENCY. Only the class where target the dependency is rewrite.
/// class Classe1 -
class Classe1 {
// Attributes
public:
Classe2 * c2;
};

endif

FILE 2 :

ifndef CLASSE2_H

define CLASSE2_H

include "Classe1.h"

class Classe1 {} // TO AVOID CIRCULAR DEPENDENCY.
/// class Classe2 -
class Classe2 {
// Attributes
public:
Classe1 c1;
};

endif

1 Attachments

Discussion

  • LE GARREC Vincent

    Dear,

    C++ generator do not detect circular dependencies (exemple enclosed). The great thing is the generator write :

    FILE 1 :
    #ifndef __CLASSE1_H__
    #define __CLASSE1_H__

    #include "Classe2.h"

    class Classe2 {} // TO AVOID CIRCULAR DEPENDENCY. Only the class where target the dependency is rewrite.
    /// class Classe1 -
    class Classe1 {
    // Attributes
    public:
    Classe2 * c2;
    };

    #endif

    FILE 2 :
    #ifndef __CLASSE2_H__
    #define __CLASSE2_H__

    #include "Classe1.h"

    class Classe1 {} // TO AVOID CIRCULAR DEPENDENCY.
    /// class Classe2 -
    class Classe2 {
    // Attributes
    public:
    Classe1 c1;
    };

    #endif

     
  • LE GARREC Vincent

    But first, to avoid the bufferoverflow, the enclosed patch should be apply.

     
  • LE GARREC Vincent

    About the second part (adding "class Classe1 {};") that prevent circular dependency, I don't have any idea to solve that problem.

     
  • Oliver Kellogg

    Oliver Kellogg - 2014-06-01

    But first, to avoid buffer overflow, the enclosed patch should be applied.

    See comment at beginning of decls.h:

    `struct declaration' is a buffer that gathers together classes and
    packages ordered by their dependencies, going from least dependencies
    to most.  We cannot handle circular dependencies yet.
    

    Your patch would break the ordering by ascending dependency?

     
  • LE GARREC Vincent

    Ohh, my… You're right. I just did a test and that didn't works with my patch. I understand now the problem with circular dependencies.

    What do you think about this new patch ? It's store on a temporary namelist every class/package at the beginning of the push function. I made some test and I didn't saw any problem.

     
  • Oliver Kellogg

    Oliver Kellogg - 2014-06-03

    Thanks for providing the new patch. I applied it on git master in commit 6c1284c.

     
  • Oliver Kellogg

    Oliver Kellogg - 2014-06-03
    • status: open --> accepted
    • Group: -->
     
  • LE GARREC Vincent

    I worked today about the second part (adding "class Classe1 {};"). Please find enclosed a patch that found circular dependencies. Modifications in generate_code_cpp are only to show (and check) the loops.

    Actually my problem is that I found loop as name of the class but not as node (so for each node, it's missing the name of the file and the complet name (with namespace)). Do you have an idea to solve that problem or to help me with the patch ?

     
  • LE GARREC Vincent

    An example. It detects only 2 of the 3 loops but it looks like it's always detect the biggest loop. So, it's okay.

     
  • Oliver Kellogg

    Oliver Kellogg - 2021-12-27
    • status: accepted --> closed
     

Log in to post a comment.