0

I wrote a small Hello, World! program in C and here it is:

#include <stdio.h>

int main()
{
    printf(“ Hello, World\n”);
    return 1;
}

Here is the make file

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := cppTestProj
LOCAL_SRC_FILES := LOCAL_SRC_FILES := helloworld.c

include $(BUILD_SHARED_LIBRARY)

When I tried executing the same from command prompt using ndk-build.cmd, I was getting some long unknown errors of this kind:

jni/helloworld.c:59:1: error: stray '\277' in program
jni/helloworld.c:59:1: error: stray '\271' in program
jni/helloworld.c:59:1: error: stray '\362' in program
jni/helloworld.c:59:1: error: stray '\224' in program
jni/helloworld.c:59:1: error: stray '\34' in program
jni/helloworld.c:59:1: error: stray '\213' in program
jni/helloworld.c:59:1: error: stray '\7' in program
jni/helloworld.c:59:1: error: stray '\35' in program
jni/helloworld.c:59:1: error: stray '\310' in program
jni/helloworld.c:59:1: error: stray '\341' in program
jni/helloworld.c:59:1: error: stray '\24' in program
jni/helloworld.c:59:1: error: stray '\330' in program
jni/helloworld.c:59:1: error: stray '\370' in program
jni/helloworld.c:59:1: error: stray '\271' in program
jni/helloworld.c:59:1: error: stray '\220' in program
jni/helloworld.c:59:1: error: stray '\203' in program
jni/helloworld.c:59:1: error: stray '\223' in program
jni/helloworld.c:59:1: error: stray '\275' in program
jni/helloworld.c:59:1: error: stray '\23' in program
jni/helloworld.c:59:1: error: stray '\302' in program
jni/helloworld.c:59:1: error: stray '\214' in program
jni/helloworld.c:59:1: error: stray '\310' in program
jni/helloworld.c:59:1: error: stray '\1' in program
jni/helloworld.c:59:1: error: stray '\252' in program
jni/helloworld.c:59:1: error: stray '\261' in program
jni/helloworld.c:59:1: error: stray '\4' in program
jni/helloworld.c:59:1: error: stray '\326' in program
jni/helloworld.c:59:1: error: stray '\255' in program
jni/helloworld.c:59:1: error: stray '\200' in program
jni/helloworld.c:59:1: error: stray '\310' in program
jni/helloworld.c:59:1: error: stray '\242' in program
jni/helloworld.c:59:1: error: stray '\373' in program
jni/helloworld.c:59:1: error: stray '\235' in program
jni/helloworld.c:59:1: error: stray '\377' in program
jni/helloworld.c:59:1: error: stray '\24' in program
jni/helloworld.c:59:1: error: stray '\366' in program
jni/helloworld.c:59:1: error: stray '\17' in program
jni/helloworld.c:59:1: error: stray '\324' in program
jni/helloworld.c:59:105: warning: null character(s) ignored [enabled by default]

jni/helloworld.c:59:1: error: stray '\355' in program
jni/helloworld.c:59:1: error: stray '\277' in program
jni/helloworld.c:59:1: error: stray '\267' in program
jni/helloworld.c:59:1: error: stray '\363' in program
jni/helloworld.c:59:1: error: stray '\274' in program
jni/helloworld.c:59:1: error: stray '\5' in program
jni/helloworld.c:59:1: error: stray '\177' in program
jni/helloworld.c:59:1: error: stray '\335' in program
jni/helloworld.c:59:1: error: stray '\377' in program
jni/helloworld.c:60:1: error: stray '\321' in program
jni/helloworld.c:60:1: error: stray '\345' in program
jni/helloworld.c:60:1: error: stray '\344' in program
jni/helloworld.c:60:87: warning: null character(s) ignored [enabled by default]
jni/helloworld.c:60:1: error: stray '\353' in program
jni/helloworld.c:60:1: error: stray '\202' in program
jni/helloworld.c:60:1: error: stray '\216' in program
jni/helloworld.c:60:1: error: stray '\255' in program
jni/helloworld.c:60:1: error: stray '\226' in program
jni/helloworld.c:60:1: error: stray '\371' in program
jni/helloworld.c:60:1: error: stray '\272' in program
jni/helloworld.c:60:1: error: stray '\211' in program
jni/helloworld.c:60:1: error: stray '`' in program
jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:1: error: stray '\21' in program
jni/helloworld.c:60:1: error: stray '\254' in program
jni/helloworld.c:60:1: error: stray '\226' in program
jni/helloworld.c:60:1: error: stray '\252' in program
jni/helloworld.c:60:1: error: stray '\321' in program
jni/helloworld.c:60:1: error: stray '\36' in program
jni/helloworld.c:60:1: error: stray '\243' in program
jni/helloworld.c:60:1: error: stray '\252' in program
jni/helloworld.c:60:1: error: stray '\246' in program
jni/helloworld.c:60:1: error: stray '\256' in program
jni/helloworld.c:60:1: error: stray '\233' in program
jni/helloworld.c:60:1: error: stray '\220' in program
jni/helloworld.c:60:1: error: stray '\377' in program
jni/helloworld.c:60:1: error: stray '\22' in program
jni/helloworld.c:60:1: error: stray '@' in program
jni/helloworld.c:60:1: error: stray '\314' in program
jni/helloworld.c:60:1: error: stray '\34' in program
jni/helloworld.c:60:1: error: stray '\361' in program
jni/helloworld.c:60:1: error: stray '\200' in program
jni/helloworld.c:60:1: error: stray '\306' in program
jni/helloworld.c:60:1: error: stray '\21' in program
jni/helloworld.c:60:1: error: stray '\4' in program
jni/helloworld.c:60:1: error: stray '\34' in program
jni/helloworld.c:60:1: error: stray '\361' in program
jni/helloworld.c:60:1: error: stray '\200' in program
jni/helloworld.c:60:1: error: stray '\206' in program
jni/helloworld.c:60:1: error: stray '\213' in program
jni/helloworld.c:60:1: error: stray '\361' in program
jni/helloworld.c:60:1: error: stray '\260' in program
jni/helloworld.c:60:1: error: stray '\310' in program
jni/helloworld.c:60:1: error: stray '\332' in program
jni/helloworld.c:60:1: error: stray '\340' in program
jni/helloworld.c:60:1: error: stray '\265' in program
jni/helloworld.c:60:1: error: stray '\336' in program
jni/helloworld.c:60:1: error: stray '\10' in program
jni/helloworld.c:60:1: error: stray '\20' in program
jni/helloworld.c:60:1: error: stray '\274' in program
jni/helloworld.c:60:1: error: stray '\371' in program
jni/helloworld.c:60:1: error: stray '\337' in program
jni/helloworld.c:60:1: error: stray '\203' in program
jni/helloworld.c:60:1: error: stray '\252' in program
jni/helloworld.c:60:1: error: stray '\342' in program
jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:165: warning: null character(s) ignored [enabled by default]

jni/helloworld.c:60:1: error: stray '\221' in program
jni/helloworld.c:60:1: error: stray '\265' in program
jni/helloworld.c:60:1: error: stray '\301' in program
jni/helloworld.c:60:1: error: stray '\251' in program
jni/helloworld.c:60:1: error: stray '\361' in program
jni/helloworld.c:60:1: error: stray '\243' in program
jni/helloworld.c:60:1: error: stray '\262' in program
jni/helloworld.c:60:1: error: stray '\356' in program
jni/helloworld.c:60:1: error: stray '\201' in program
jni/helloworld.c:60:1: error: stray '\225' in program
jni/helloworld.c:60:1: error: stray '\356' in program
jni/helloworld.c:60:1: error: stray '\20' in program
jni/helloworld.c:60:1: error: stray '\4' in program
jni/helloworld.c:60:1: error: stray '\205' in program
jni/helloworld.c:60:1: error: stray '\34' in program
jni/helloworld.c:60:1: error: stray '\240' in program
jni/helloworld.c:60:1: error: stray '\246' in program
jni/helloworld.c:60:1: error: stray '#' in program
jni/helloworld.c:60:1: error: stray '\344' in program
jni/helloworld.c:60:1: error: stray '\350' in program
jni/helloworld.c:60:1: error: stray '\264' in program
jni/helloworld.c:60:1: error: stray '\211' in program
jni/helloworld.c:60:1: error: stray '\202' in program
jni/helloworld.c:60:1: error: stray '\5' in program
jni/helloworld.c:60:1: error: stray '\257' in program
jni/helloworld.c:60:1: error: stray '\241' in program
jni/helloworld.c:60:1: error: stray '\306' in program
jni/helloworld.c:60:1: error: stray '\362' in program
jni/helloworld.c:60:1: error: stray '\207' in program
jni/helloworld.c:60:1: error: stray '`' in program
jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:1: error: stray '#' in program
jni/helloworld.c:60:1: error: stray '\336' in program
jni/helloworld.c:60:1: error: stray '\10' in program
jni/helloworld.c:60:1: error: stray '\320' in program
jni/helloworld.c:60:1: error: stray '\342' in program
jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:216: warning: null character(s) ignored [enabled by default]

jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:1: error: stray '#' in program
jni/helloworld.c:60:1: error: stray '\336' in program
jni/helloworld.c:60:1: error: stray '\10' in program
jni/helloworld.c:60:1: error: stray '\320' in program
jni/helloworld.c:60:1: error: stray '\342' in program
jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:225: warning: null character(s) ignored [enabled by default]

jni/helloworld.c:60:1: error: stray '\215' in program
jni/helloworld.c:60:1: error: stray '#' in program
jni/helloworld.c:60:1: error: stray '\336' in program
jni/helloworld.c:60:1: error: stray '\10' in program
jni/helloworld.c:60:1: error: stray '\320' in program
jni/helloworld.c:60:1: error: stray '\361' in program
jni/helloworld.c:60:1: error: stray '\356' in program
jni/helloworld.c:60:1: error: stray '\207' in program
jni/helloworld.c:60:1: error: stray '\214' in program
jni/helloworld.c:60:236: warning: missing terminating ' character [enabled by de
fault]
jni/helloworld.c:60:1: error: missing terminating ' character
jni/helloworld.c:61:1: error: stray '\233' in program
jni/helloworld.c:61:1: error: stray '\361' in program
jni/helloworld.c:61:1: error: stray '\267' in program
jni/helloworld.c:61:1: error: stray '\213' in program
jni/helloworld.c:61:1: error: stray '\202' in program
jni/helloworld.c:61:1: error: stray '\16' in program
jni/helloworld.c:61:1: error: stray '\274' in program
jni/helloworld.c:61:1: error: stray '\21' in program
jni/helloworld.c:61:1: error: stray '\24' in program
jni/helloworld.c:61:1: error: stray '\202' in program
jni/helloworld.c:61:1: error: stray '\352' in program
jni/helloworld.c:61:1: error: stray '\16' in program
jni/helloworld.c:61:1: error: stray '\301' in program
jni/helloworld.c:61:22: warning: missing terminating " character [enabled by def
ault]
jni/helloworld.c:61:1: error: missing terminating " character
jni/helloworld.c:62:1: error: stray '\344' in program
jni/helloworld.c:62:1: error: stray '\267' in program
jni/helloworld.c:62:1: error: stray '\213' in program
jni/helloworld.c:62:1: error: stray '\202' in program
jni/helloworld.c:62:1: error: stray '\16' in program
jni/helloworld.c:62:1: error: stray '\274' in program
jni/helloworld.c:62:1: error: stray '\21' in program
jni/helloworld.c:62:1: error: stray '\24' in program
jni/helloworld.c:62:1: error: stray '\202' in program
jni/helloworld.c:62:1: error: stray '\352' in program
jni/helloworld.c:62:1: error: stray '\305' in program
jni/helloworld.c:62:1: error: stray '\33' in program
jni/helloworld.c:62:1: error: stray '\301' in program
jni/helloworld.c:62:22: warning: missing terminating " character [enabled by def
ault]
jni/helloworld.c:62:1: error: missing terminating " character
jni/helloworld.c:63:1: error: stray '\366' in program
jni/helloworld.c:63:1: error: stray '\234' in program
jni/helloworld.c:63:1: error: stray '\255' in program
jni/helloworld.c:63:1: error: stray '\212' in program
jni/helloworld.c:63:1: error: stray '\236' in program
jni/helloworld.c:63:1: error: stray '\322' in program
jni/helloworld.c:63:1: error: stray '\222' in program
jni/helloworld.c:63:1: error: stray '\4' in program
jni/helloworld.c:63:1: error: stray '\330' in program
jni/helloworld.c:63:1: error: stray '\6' in program
jni/helloworld.c:63:1: error: stray '\345' in program
jni/helloworld.c:63:1: error: stray '\251' in program
jni/helloworld.c:63:1: error: stray '\6' in program
jni/helloworld.c:63:19: error: invalid suffix "p" on integer constant
jni/helloworld.c:63:1: error: stray '\326' in program
jni/helloworld.c:63:1: error: stray '\22' in program
jni/helloworld.c:63:1: error: stray '\260' in program
jni/helloworld.c:63:1: error: stray '\230' in program
jni/helloworld.c:63:1: error: stray '\340' in program
jni/helloworld.c:63:1: error: stray '\276' in program
jni/helloworld.c:63:1: error: stray '\345' in program
jni/helloworld.c:63:1: error: stray '\271' in program
jni/helloworld.c:63:1: error: stray '\351' in program
jni/helloworld.c:63:1: error: stray '\342' in program
jni/helloworld.c:63:1: error: stray '\375' in program
jni/helloworld.c:63:1: error: stray '\247' in program
jni/helloworld.c:63:1: error: stray '\6' in program
jni/helloworld.c:63:1: error: stray '\2' in program
jni/helloworld.c:63:1: error: stray '\313' in program
jni/helloworld.c:63:1: error: stray '\31' in program
jni/helloworld.c:63:1: error: stray '\22' in program
jni/helloworld.c:63:1: error: stray '\210' in program
jni/helloworld.c:63:1: error: stray '\351' in program
jni/helloworld.c:63:1: error: stray '\201' in program
jni/helloworld.c:63:1: error: stray '\235' in program
jni/helloworld.c:63:1: error: stray '\342' in program
jni/helloworld.c:63:1: error: stray '\177' in program
jni/helloworld.c:63:1: error: stray '\4' in program
jni/helloworld.c:63:1: error: stray '\270' in program
jni/helloworld.c:63:1: error: stray '\203' in program
jni/helloworld.c:63:1: error: stray '\335' in program
jni/helloworld.c:63:1: error: stray '\363' in program
jni/helloworld.c:63:1: error: stray '\226' in program
jni/helloworld.c:63:1: error: stray '\4' in program
jni/helloworld.c:63:1: error: stray '\243' in program
jni/helloworld.c:63:1: error: stray '\304' in program
jni/helloworld.c:63:1: error: stray '\25' in program
jni/helloworld.c:63:1: error: stray '\22' in program
jni/helloworld.c:63:1: error: stray '\216' in program
jni/helloworld.c:63:1: error: stray '\337' in program
jni/helloworld.c:63:1: error: stray '\303' in program
jni/helloworld.c:63:1: error: stray '\235' in program
jni/helloworld.c:63:1: error: stray '#' in program
jni/helloworld.c:63:1: error: stray '\302' in program
jni/helloworld.c:63:1: error: stray '\331' in program
jni/helloworld.c:63:1: error: stray '\321' in program
jni/helloworld.c:63:1: error: stray '\365' in program
jni/helloworld.c:63:1: error: stray '\317' in program
jni/helloworld.c:63:1: error: stray '\360' in program
jni/helloworld.c:63:1: error: stray '\311' in program
jni/helloworld.c:63:1: error: stray '\300' in program
jni/helloworld.c:63:1: error: stray '\306' in program
jni/helloworld.c:63:1: error: stray '\272' in program
jni/helloworld.c:63:1: error: stray '\207' in program
jni/helloworld.c:63:1: error: stray '\252' in program
jni/helloworld.c:63:1: error: stray '\355' in program
jni/helloworld.c:63:1: error: stray '\320' in program
jni/helloworld.c:63:1: error: stray '\236' in program
jni/helloworld.c:63:1: error: stray '\33' in program
jni/helloworld.c:63:1: error: stray '\207' in program
jni/helloworld.c:63:1: error: stray '\214' in program
jni/helloworld.c:63:1: error: stray '\237' in program
jni/helloworld.c:63:1: error: stray '\372' in program
jni/helloworld.c:63:1: error: stray '\366' in program
jni/helloworld.c:63:1: error: stray '\345' in program
jni/helloworld.c:63:1: error: stray '\311' in program
jni/helloworld.c:63:1: error: stray '\315' in program
jni/helloworld.c:63:1: error: stray '\10' in program
jni/helloworld.c:63:1: error: stray '\331' in program
jni/helloworld.c:63:1: error: stray '\276' in program
jni/helloworld.c:63:1: error: stray '\256' in program
jni/helloworld.c:63:1: error: stray '\242' in program
jni/helloworld.c:63:1: error: stray '\5' in program
jni/helloworld.c:63:1: error: stray '\10' in program
jni/helloworld.c:63:1: error: stray '\372' in program
jni/helloworld.c:63:1: error: stray '\320' in program
jni/helloworld.c:63:1: error: stray '\321' in program
jni/helloworld.c:63:1: error: stray '\326' in program
jni/helloworld.c:63:1: error: stray '\7' in program
jni/helloworld.c:63:1: error: stray '\333' in program
jni/helloworld.c:63:1: error: stray '\37' in program
jni/helloworld.c:63:1: error: stray '\363' in program
jni/helloworld.c:63:139: warning: null character(s) preserved in literal [enable
d by default]
jni/helloworld.c:63:139: warning: missing terminating " character [enabled by de
fault]
jni/helloworld.c:63:1: error: missing terminating " character
make: *** [obj/local/armeabi/objs/cppTestProj/helloworld.o] Error 1

What is the issue?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • There are less than 10 lines in the posted code. The errors indicate line 59, line 60, line 61, line 62, and line 63. The posted code would result in the two compile error triplets `\342 \200 \230` and `\342 \200 \231`, corresponding to U+2013 ([LEFT SINGLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8704&number=128)) and U+2013 ([RIGHT SINGLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8704&number=128)). – Peter Mortensen Apr 27 '23 at 15:47
  • Though it looks more like [CE/CP-1250](https://en.wikipedia.org/wiki/Windows-1250) encoding (or similar), not UTF-8 (most of them start with octal `302` or `342`). For example, \221 for the corresponding CE/CP-1250 for U+2013 ([RIGHT SINGLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8704&number=128)) – Peter Mortensen Apr 27 '23 at 15:55
  • Correction: U+2018 ([LEFT SINGLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128)) and U+2019 ([RIGHT SINGLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128)) – Peter Mortensen Apr 27 '23 at 16:13
  • In any case, 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. The canonical question is *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332)*. – Peter Mortensen Apr 27 '23 at 16:14
  • OK, the reported errors look more like the compiler chewing on a binary file, not UTF-8 sequences (probably not caused by copy-pasting. But the listed source is. The listed source and the listed errors seem to be out of sync). Similar for binary data: *[Daemon on embedded Linux device using Busybox be written in C or as a script](https://stackoverflow.com/questions/28759855/daemon-on-embedded-linux-device-using-busybox-be-written-in-c-or-as-a-script)* – Peter Mortensen Apr 28 '23 at 20:02

2 Answers2

3

The quote characters around your string “ Hello world\n” are fancy quotes - see how they point up and down? Replace with plain ASCII ones. Did you edit your file in MS Word? Word, and other document-oriented text editors, sometimes replace plain quotes with fancy ones. Better use an ASCII editor like Notepad (on Windows), or a programming IDE like Eclipse.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
1

You are compiling a library with main:

See the last line in your android.mk file:

include $(BUILD_SHARED_LIBRARY)

To build a binary, use:

include $(BUILD_EXECUTABLE)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
medazzo
  • 99
  • 5
  • Yes, this seems more likely for the reported error. Though the source by itself would result in the two triplets (stray error) \342 \200 \234 and \342 \200 \235 (not in the reported errors). – Peter Mortensen Apr 28 '23 at 20:03