eProsima/Fast-DDS-Gen

fastddsgen generates invalid #ifndef header fence on IDL filename with "-"

Opened this issue · 1 comments

For an IDL file named outer-middle-inner.idl with content

module outer {
   module middle {
      module inner {
         enum some_type { A, B, C };
      };
   };
};

fastddsgen generates the start of header file

#ifndef _FAST_DDS_GENERATED_OUTER-MIDDLE-INNER_H_
#define _FAST_DDS_GENERATED_OUTER-MIDDLE-INNER_H_

Notice that the dashes from the input filename are directly transferred to the header guard symbol.
Looking at src/main/java/com/eprosima/fastdds/idl/grammar/Context.java function getHeaderGuardName,

            if (m_lastStructure.getHasScope())
            {
                return m_lastStructure.getScope().replaceAll("::", "_").toUpperCase() +
                       "_" + m_fileNameUpper.replaceAll("\\.", "_");
            }

IMHO it would be good to extend the pattern in the m_fileNameUpper.replaceAll to include "-".

See also IDL-Parser pull request 73 (Support idl files with '-' character)