0

I am super new to C, I usually use javascript, but I am working on a hardware project and there is no library for js that I could find. I am using a MD_MAX7219 led matrix with a esp8266 node mcu and am using mongoose os basic c github repo mos clone https://github.com/mongoose-os-apps/empty

I am probably not using C in the correct way, but thought I would just give it a crack. I'm gonna find some good C tutorials anyways, but wanted to see if I could just read the docs and get it to work.

I have the following code which fails to build with mos build

#include "mgos.h"
#include "MD_MAX72xx.h"

MD_MAX72XX(13, 14, 15, 1);

void begin(void)

    bool drawLine(0, 0, 1, 5, bool state);

mos.yml

author: mongoose-os
description: A Mongoose OS app skeleton
version: 1.0

libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}

# Optional. List of tags for online search.
tags:
  - c

# List of files / directories with C sources. No slashes at the end of dir names.
sources:
  - src

# List of dirs. Files from these dirs will be copied to the device filesystem
filesystem:
  - fs

libs:
  - origin: https://github.com/mongoose-os-libs/boards
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/md-max72xx
  - origin: https://github.com/mongoose-os-libs/arduino-compat

# Used by the mos tool to catch mos binaries incompatible with this file format
manifest_version: 2017-09-29

I get the following errors

unknown type name 'class'
  284 | class MD_MAX72XX
      | ^~~~~
/data/fwbuild-volumes/2.18.0/apps/mdmax72/esp8266/build_contexts/build_ctx_776553971/deps/md-max72xx/include/MD_MAX72xx.h:285:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
  285 | {
      | ^
/data/fwbuild-volumes/2.18.0/apps/mdmax72/esp8266/build_contexts/build_ctx_776553971/src/main.c:21:12: error: expected declaration specifiers or '...' before numeric constant
   21 | MD_MAX72XX(13, 14, 15, 1);

So I am guessing I need to instantiate the class differently. Not sure, Thanks ahead of time

Anders Kitson
  • 1,413
  • 6
  • 38
  • 98
  • 1
    It looks like what you are trying to use is a C++ library, so you will have to write some wrapper code to use it from C. – MikeCAT Nov 27 '20 at 16:13
  • could you point me to somewhere on how I would do such a thing – Anders Kitson Nov 29 '20 at 21:06
  • and in the docs why does it call it a c header that I am pointing too, if you say it's c++ https://mongoose-os.com/docs/mongoose-os/api/drivers/md-max72xx.md – Anders Kitson Nov 29 '20 at 21:07
  • Because the library author is not so good at writing documents? C do not have syntaxes for classes. – MikeCAT Dec 05 '20 at 23:50

0 Answers0