sunwait icon indicating copy to clipboard operation
sunwait copied to clipboard

Syntax error in sunwait.cpp

Open goverp opened this issue 3 years ago • 5 comments

Hi, thanks for this very useful piece of code that I've used for some time. I've just cloned it onto my new Raspberry Pi and tried to run "make", and it fails in compilation in sunwait.cpp at lines 707 on, where the if statement has incorrect bracketing. I think it should be:

else if   (!strcmp (arg, "debug")           ||
              !strcmp (arg, "--debug")      ||
              !strcmp (arg, "--verbose")    ||
              !strcmp (arg, "-v"))           pRun->debug = ONOFF_ON;

If I trusted my C++ and git skills more, I'd send a pull request.

goverp avatar Aug 15 '22 11:08 goverp

Same issue when building as OpenWRT package:

...
/tmp/openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/sunwait-1.0/sunwait.cpp: In function 'int main(int, char**)':
/tmp/openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/sunwait-1.0/sunwait.cpp:707:47: error: expected primary-expression before '||' token
  707 |     else if   (!strcmp (arg, "debug"))        ||
      |                                               ^~
make[2]: *** [Makefile:42: /tmp/openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/sunwait-1.0/.built] Error 1
...

Overcomed with exact version setting in Makefile:

PKG_SOURCE_VERSION:=102cb417ecbb7a3757ba9ee4b94d6db3225124c4

(Before problematic 22b741a60ff6d5f8b8fac18d998c58c9aa13d3c8 commit)

petrjac avatar Sep 11 '22 10:09 petrjac

Trying to compile on RASPI Bullseye.

Excuse my ignorance, but I have placed the line cited above "PKG_SOURCE_VERSION:=102cb417ecbb7a3757ba9ee4b94d6db3225124c4" after the line beginning "LDFLAGS..." in makefile and I get the same error as reported by "sebma".

makefile.txt

likemotion avatar Sep 12 '22 15:09 likemotion

@likemotion using the PKG_SOURCE_VERSION is valid only for OpenWRT specific makefile.

You could probably try clone the repository and then switch version:

git clone https://github.com/risacher/sunwait.git
cd sunwait
git checkout 102cb417ecbb7a3757ba9ee4b94d6db3225124c4
make

petrjac avatar Sep 12 '22 15:09 petrjac

Thanks very much Peter for your help; sorry for the delay in following-up - its now working and can now get on with the next stage.

Fab service!

Cheers,

Mike

FYI here's the output I got:

@.:~/sunwait $ make gcc -c -Wall sunwait.cpp -o sunwait.o sunwait.cpp: In function 'int main(int, char)': sunwait.cpp:665:62: warning: value computed is not used [-Wunused-value] 665 | if (arg[0] == '-' && arg[1] != '\0' && !isdigit(arg[1])) arg++; | ^~~~~~ gcc -c -Wall sunriset.cpp -o sunriset.o sunriset.cpp: In function 'void sun_RA_dec(double, double, double, double*)': sunriset.cpp:151:18: warning: variable 'zs' set but not used [-Wunused-but-set-variable] 151 | double xs, ys, zs; | ^~ gcc -c -Wall print.cpp -o print.o gcc sunwait.o sunriset.o print.o -o sunwait -lm -lstdc++

----- Original Message ----- From: "petrjac" @.> To: "risacher/sunwait" @.> Cc: "likemotion" @.>, "Mention" @.> Sent: Monday, 12 September, 2022 5:35:43 PM Subject: Re: [risacher/sunwait] Syntax error in sunwait.cpp (Issue #37)

@likemotion using the PKG_SOURCE_VERSION is valid only for OpenWRT specific makefile .

You could probably try clone the repository and then switch version: git clone https://github.com/risacher/sunwait.git cd sunwait git checkout 102cb417ecbb7a3757ba9ee4b94d6db3225124c4 make

— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: <risacher/sunwait/issues/37/1243920955 @ github . com>

likemotion avatar Sep 12 '22 17:09 likemotion

Hi @likemotion

happy to hear that. This is only warnings from compiler.

You can run sunwait from current directory:

pi@raspberrypi:/tmp/sunwait $ ./sunwait help

petrjac avatar Sep 12 '22 17:09 petrjac