0

in a c++ project I have two header files. in the first header file there is a struct that I want to instantiate as an array in the second file.
at the initialization of the first member at the second index of array I get the error.

    h1.h
    -----------
   // typedefs of U32,F32,B1,...
    typedef struct {
        U32 ID;
        B1 Ext;
        U32 Len;
        U8 Data[8];
    } Msg;

this is the second file

h2.h
-------
#include "h1.h"
Msg canMessages[2] = {
    {
        215613444,
        true,
        8,
        {'ñ','\x10','í','Z','\v','\0','\x4','\0'}
    },{
        217056257‭, //** HERE I GET THE ERROR
        true,
        5,
        {'ñ','\x3','Ä','\x1','¤','\0','\0','\0'}
    }
};

E2474 user-defined literal operator not found.

C3688 invalid literal suffix '‭'; literal operator or literal operator template 'operator ""‭' not found.

Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123
  • Your posted code has 7 ending the literal, then `\xe2\x80\xad`, then a comma. What's that middle part? – chris Nov 06 '18 at 19:37
  • 1
    @eukaryota it is c++, the code base is not mine just modifying it. at the beginning there was no error, when I changed the value this error appeared. – Amir-Mousavi Nov 06 '18 at 19:38
  • 1
    Check for invisible characters. There is a "stray `\342` in program" (and a few more) https://godbolt.org/z/NQUHId – Justin Nov 06 '18 at 19:38
  • 2
    Voting to close as a typo. You have invisible Unicode characters in your source code. – NathanOliver Nov 06 '18 at 19:38
  • My bad, it's a [LTR override](http://www.fileformat.info/info/unicode/char/202d/index.htm) between the literal and comma. – chris Nov 06 '18 at 19:39
  • @chris where are these characters? `\xe2\x80\xad` – Amir-Mousavi Nov 06 '18 at 19:42
  • 1
    I strongly recommend not putting non-ASCII characters inside character literals either. For example, the moment a compiler treats your source as UTF-8, your `'ñ'` character literal is actually two: C3 B1 – chris Nov 06 '18 at 19:42
  • @NathanOliver what is counted as invisible Unicode char ? can you explain more? – Amir-Mousavi Nov 06 '18 at 19:44
  • @Amir-Mousavi, Those are between `217056257‭` and `,`. You can use xxd or another tool like [this one](https://r12a.github.io/app-conversion/) to verify it yourself. The actual character is the LTR override. I mistakenly took it as UTF-8 at first. – chris Nov 06 '18 at 19:45
  • Sidenote: C++ has 20-some years of evolution of C that C didn't get to take advantage of. `typedef struct { ... } Msg;` can be `struct Msg { ... };` – user4581301 Nov 06 '18 at 19:55

0 Answers0