Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-17504

BEGINC++ vs EMBED(C++) within a FUNCTIONMACRO

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.2.12
    • Fix Version/s: 6.4.0
    • Component/s: Code Generator
    • Labels:
      None

      Description

      Using sample code taken from another project:

      SomeFunc() := FUNCTIONMACRO
      
          STRING MarkNodes(STRING l, STRING l_nodes, STRING n, STRING n_nodes) := BEGINC++
              #option pure
              #body
              unsigned long i = 0;
              char * out = (char*)rtlMalloc(lenN_nodes);
              memcpy(out, n_nodes, lenN_nodes);
              while ( i < lenN){
                      if (l[i] != n[i] || i >= lenL){
                          out[i] = '1';
                          break;
                      }
                      if (l_nodes[i] != n_nodes[i]){
                          out[i] = '1';
                      }
                      i += 1;
              }
              __lenResult = lenN_nodes;
              __result = out;
          ENDC++;
      
      /*
          STRING MarkNodes(STRING l, STRING l_nodes, STRING n, STRING n_nodes) := EMBED(C++ : DISTRIBUTED)
              #option pure
              #body
              unsigned long i = 0;
              char * out = (char*)rtlMalloc(lenN_nodes);
              memcpy(out, n_nodes, lenN_nodes);
              while ( i < lenN){
                      if (l[i] != n[i] || i >= lenL){
                          out[i] = '1';
                          break;
                      }
                      if (l_nodes[i] != n_nodes[i]){
                          out[i] = '1';
                      }
                      i += 1;
              }
              __lenResult = lenN_nodes;
              __result = out;
          ENDEMBED;
      */
      
          RETURN MarkNodes('v1', 'v2', 'v3', 'v4');
      ENDMACRO;
      
      SomeFunc();
      

      The code as-is works (though the resulting value is nonsense). If you switch around the comments so the EMBED(C++) version of the function is exposed then a number of errors appear (e.g. "Unknown # command: #body").

        Attachments

          Activity

            People

            • Assignee:
              richardkchapman Richard Chapman
              Reporter:
              dcamper Dan S. Camper
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: