Confdc more detail about enum conflicts

Is there a command line option for confdc to give more detail about where the enum conflict is happening other than just the name?

I’m getting

Warning: the following symbols have been suppressed due to a
conflict with an enum or bit with the same mapped name but a different value:
 'UNKNOWN'.

when compiling a module, and I’ve gone through the module and I’m fairly sure all its imports (and imports imports!), and added a unique code-name to all instances of enum UNKNOWN I can find, but I’m still getting the error.

Side question, I notice bit enums append their own namespace to the #define.

Any reason why enumeration enums don’t append their own typedef name as well? Or a way to force that through a command option?

See the confdc(1) man page for what your options are:

...
--macro-prefix Prefix
           Without this option, all macro definitions in the generated .h file are prepended with the argument of the prefix statement in the YANG module. If this
           option is used, the macro definitions are prepended with Prefix instead.
...
--exclude-enums
           If this option is used, macro definitions for enums are omitted from the generated .h file. This can in some cases be useful to avoid conflicts between
           enum symbols, or between enums and other symbols.
...

There’s no way to assign a prefix per typedef though is there? It’s per .fxs?

In my code, module a imports b, c, and d. All 3 imports define a typedef for enumeration (each typedef has a different name) containing a enum UNKNOWN, each with a different value.

I need to add code-names to each typedef?

If you are using confdc flags it is per YANG module/FXS file.
If you want to assign a prefix on some enum but not some other, then you need to use tailf:code-name.

And there’s no way to code-name an entire enumeration in a typedef, it’s per-enum, right?

Main reason I’m asking is I’m not really looking forward to tracking down 58 typedefs to add a code-name to each’s enum for “UNKNOWN”…

If there are 58 typedefs with enums in them I suggest you first add those tailf:code-name + tailf-common import statements directly into a copy of the original YANG file and then generate the annotation file using this Python script:

Quick demo:

$ cat yang-orig/module-d.yang 
module module-d {
  yang-version 1;
  namespace "urn:params:xml:ns:yang:project:m-d";
  prefix m-d;

  import tailf-common { prefix tailf; }

  typedef module-d-type {
    type enumeration {
      enum OTHER {
        tailf:code-name "m-d-type-OTHER";
        value 1;
      }
      enum UNKNOWN {
        tailf:code-name "m-d-type-UNKNOWN";
        value 0;
      }
    }
  }

  typedef module-d-type2 {
    type enumeration {
      enum OTHER {
        tailf:code-name "m-d-type2-OTHER";
        value 1;
      }
      enum UNKNOWN {
        tailf:code-name "m-d-type2-UNKNOWN";
        value 0;
      }
    }
  }
}

$ python3 tailf_ann_stmt.py -t yang-orig/module-d.yang -o .
$ cat ./module-d-ann.yang 
module module-d-ann {
  namespace "urn:params:xml:ns:yang:project:m-d-ann";
  prefix m-d-ann;

  import tailf-common {
    prefix tailf;
  }

  revision 2022-04-08 {
    description
      "Initial revision";
  }
  tailf:annotate-module "module-d" {
    tailf:annotate-statement "typedef[name='module-d-type']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='OTHER']" {
          tailf:code-name "m-d-type-OTHER";
        }
      }
    }
    tailf:annotate-statement "typedef[name='module-d-type']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='UNKNOWN']" {
          tailf:code-name "m-d-type-UNKNOWN";
        }
      }
    }
    tailf:annotate-statement "typedef[name='module-d-type2']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='OTHER']" {
          tailf:code-name "m-d-type2-OTHER";
        }
      }
    }
    tailf:annotate-statement "typedef[name='module-d-type2']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='UNKNOWN']" {
          tailf:code-name "m-d-type2-UNKNOWN";
        }
      }
    }
  }
}

$ cat ./module-d.yang 
module module-d {
  yang-version 1;
  namespace "urn:params:xml:ns:yang:project:m-d";
  prefix m-d;

  typedef module-d-type {
    type enumeration {
      enum OTHER {
        value 1;
      }
      enum UNKNOWN {
        value 0;
      }
    }
  }

  typedef module-d-type2 {
    type enumeration {
      enum OTHER {
        value 1;
      }
      enum UNKNOWN {
        value 0;
      }
    }
  }
}

OMG thank you so much!

Wish there was a way to have it generate those annotation-statement blocks based on any enums it finds, but this will definitely cut down on my workload.

Using that quite simple Python script as inspiration, you can likely easily create a script that generates tailf:annotate-statement:s for enum statements found in a YANG file according to your needs.

I wish it handled enums the same way protobufs do (enumeration uses its name as the prefix for all the enums within) but I will look into crafting a python script to use the typedef name as the prefix.