1

I've been trying to run AT commands project, and have read many threads to ease the trouble. atinout (C-Program) offers lot of hope. But when I try to compile it with Turbo C++ I get the following error:

Turbo C++ Version 3.00 Copyright (c) 1992 Borland International
atinout.c:
Error atinout.c 81: Declaration syntax error
*** 1 errors in Compile ***

Actual Program (Many thanks to expert Håkon Løvdal, for making it) Sorry, I've not put the entire code here.

Line 81: Starts at static bool tr_lf_cr(const char *s)

/* Replace '\n' with '\r', aka `tr '\012' '\015'` */
static bool tr_lf_cr(const char *s)
{
char *p;
p = strchr(s, '\n');
if (p == NULL || p[1] != '\0') {
return false;
}
*p = '\r';
return true;
}
Alex P.
  • 30,437
  • 17
  • 118
  • 169
Susan M
  • 33
  • 3
  • I see one possibility and can guess at another. 1) is `true` and `false` defined, (in modern C compilers, that requires: `#include ` 2) the problem is actually in the code BEFORE line 81, not at line 81. – user3629249 Feb 19 '16 at 05:41
  • I ran the included makefile by changing to the directory that contains everything, then on the command line entering `make` it ran with no warnings/errors and produced the executable `atinout`, What are you doing different? – user3629249 Feb 19 '16 at 05:42

1 Answers1

0

user3629249 is spot on with the comment's first suggestion; the problem for tcc is the bool type. Turbo C++ 3.00 is an older compiler that only supports the C language from when it was standardized in 1990 ("ISO/IEC 9899:1990" aka C89 or C90), and the stdbool header file and corresponding boolean type was introduced in 1999 ("ISO/IEC 9899:1999" aka C99).

To make the code compile you can add the following at the beginning of the file:

#define bool int
#define true 1
#define false 0

however that will only give you a binary that run on Intel/AMD computers. Most likely your android device will be running an ARM CPU, so in order to make a binary that can be run in the adb shell you need to compile it with a cross compiler. I have not done this myself so I am unable to give any further assistance on that.


On a side note, I am in the process of converting the atinout project to use autoconf/automake + gnulib. Not because I am a huge fan, but it will support portability issues like stdbool largely out of the box and make cross compilation relatively easy. But do not hold your breath waiting for this to be finished.

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • Thanks, You folks are right that it was with bool type true/false. But to cut the time I ran it with CodeBlocks and the error was different line, which I subsequently corrected and made out exe file. With this solved I'm on 2nd stage on how to run this exe file on $ adb shell without root access? – Susan M Feb 22 '16 at 06:11