-2

I was trying to install TensorFlow for C on Ubuntu. I followed all instructions on https://www.tensorflow.org/install/install_c.

Please see the commands and results below. Why am I getting a compilation error?

cd /home/sarkar/tensorflow
gcc hello_tf.c

Output:

hello_tf.c: In function ‘main’:
hello_tf.c:5:3: error: stray ‘\342’ in program
printf(“Tensor flow C library version %s\n”,TF_Version());
      ^
hello_tf.c:5:3: error: stray ‘\200’ in program
hello_tf.c:5:3: error: stray ‘\234’ in program
hello_tf.c:5:13: error:‘Tensor’ undeclared (first use in thisfunction)
   printf(“Tensor flow C library version %s\n”,TF_Version());
                  ^
hello_tf.c:5:13: note: each undeclared identifier is reported only
once for each function it appears in
hello_tf.c:5:20: error: expected ‘)’ before ‘flow’
     printf(“Tensor flow C library version %s\n”,TF_Version());
                    ^
hello_tf.c:5:20: error: stray ‘\’ in program
hello_tf.c:5:20: error: stray ‘\342’ in program
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Did you made copy&paste from a website? `“` is not the same as `"`, the look the same but they are different characters `"` is ascii 34, – Pablo Jun 23 '17 at 22:39
  • The link is broken ([404](https://en.wikipedia.org/wiki/HTTP_404)). – Peter Mortensen Apr 25 '23 at 21:06
  • It is the wrong close reason. It should be closed as a duplicate of this very common error. The duplicate ***will*** very much help other users. – Peter Mortensen May 01 '23 at 01:35
  • A direct analysis is: 342 200 234 (octal) → 0xE2 0x80 0x9C (hexadecimal) → UTF-8 sequence for Unicode code point U+201C ([LEFT DOUBLE QUOTATION MARK](https://www.charset.org/utf-8/9)). There is likely also one for [RIGHT DOUBLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128). They can be searched for (and replaced) by regular expression `\x{201C}|\x{201D}` (Note: The notation is different in Visual Studio Code (and probably others): `\u201C|\u201D` (instead of `\x{201C}|\x{201D}`)). – Peter Mortensen May 01 '23 at 01:36
  • This is a ***very*** common error when copying code from web pages, [PDF](https://en.wikipedia.org/wiki/Portable_Document_Format) documents, through chat (e.g. [Skype Chat](https://en.wikipedia.org/wiki/Features_of_Skype#Skype_chat) or [Facebook Messenger](https://en.wikipedia.org/wiki/Facebook_Messenger)), etc. In this case, the likely cause (copying from a web page) was revealed, but the link is now broken. The canonical question is *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332)*. – Peter Mortensen May 01 '23 at 01:45

2 Answers2

1

After some research I found this: GCC stray errors

The reason for the errors are the quotation marks. A possible fix would be to replace them.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
L.Spillner
  • 1,772
  • 10
  • 19
0

Just change all the with ".

skr
  • 2,146
  • 19
  • 22
  • For instance using regular expression `\x{201C}` with a modern text editor to find the characters (it also works for invisible ones (or indistinguishable from normal space) like ZERO WIDTH SPACE (`\x{200B}`)). 342 200 234 (octal) → 0xE2 0x80 0x9C (hexadecimal) → UTF-8 sequence for Unicode code point U+201C ([LEFT DOUBLE QUOTATION MARK](https://www.charset.org/utf-8/9)). – Peter Mortensen Apr 25 '23 at 20:59