risacher / sunwait

Sunwait calculates sunrise or sunset times with civil, nautical, astronomical and custom twilights, for use with Windows Task Scheduler or 'cron' on Linux.
GNU General Public License v3.0
193 stars 45 forks source link

Syntax error in sunwait.cpp #37

Open goverp opened 2 years ago

goverp commented 2 years ago

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.

petrjac commented 2 years ago

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)

likemotion commented 2 years ago

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

petrjac commented 2 years ago

@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
likemotion commented 2 years ago

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>

petrjac commented 2 years ago

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