Giter Site home page Giter Site logo

unexpected string literal "C" about c-for-go HOT 7 CLOSED

xlab avatar xlab commented on August 16, 2024
unexpected string literal "C"

from c-for-go.

Comments (7)

cznic avatar cznic commented on August 16, 2024 1

This seems like a C++ only header file to me. The extern "C" { should be, for C compatibility, wrapped in

#ifdef __cplusplus
extern "C" {
#endif

See also: Combining C++ and C - how does #ifdef __cplusplus work?

from c-for-go.

5k3105 avatar 5k3105 commented on August 16, 2024 1

Hi,

H file same as above.

Working on this again. Error was:

unexpected identifier set_work_dir, expected one of ['(', ')', ',', ':', etc...

Changing

void DEX_API set_work_dir( const char *pName);

to (removing DEX_API)

void set_work_dir(const char *pName);

allows it to compile without error, but it's still an empty dexapi.go file.

yml is

--- 
GENERATOR: 
  PackageName: dexapi
  PackageDescription: "Package dexapi provides Go bindings for Dex Tools 2.23 for IWR3 decode to DF3"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  Includes: ["DexApi.h"]
    
PARSER: 
  SourcesPaths: ["DexApi.h"]

  Rules: 
    global:
      - {action: accept, from: "^set_work_dir$"}
      - {action: accept, from: "^make_strips$"}
      - {action: accept, from: "^list_forward$"}
      - {action: accept, from: "^list_phy_toc$"}

result dexapi.go is:

package dexapi

/*
#include "DexApi.h"
#include <stdlib.h>
#include "cgo_helpers.h"
*/
import "C"

from c-for-go.

5k3105 avatar 5k3105 commented on August 16, 2024

That worked. Now I have:

processing dexapi.yml ⠋[ERR] DexApi.h:32:14: unexpected identifier set_work_dir

from c-for-go.

5k3105 avatar 5k3105 commented on August 16, 2024

Moved #ifdef __cplusplus to top of file and endif to bottom. Compiled.

.. basically an empty file. oops

from c-for-go.

xlab avatar xlab commented on August 16, 2024

@5k3105 Have you used this?

from c-for-go.

xlab avatar xlab commented on August 16, 2024

@5k3105 Also, everything is ignored by default, you should include functions and other types you want to use explicitly. Remember nidaqmx.yml?

  Rules: 
    global:   
      - {action: accept, from: "^DAQmx"}
      - {action: replace, from: "^DAQmx"}
      - {transform: export}
    post-global: 
      - {action: replace, from: _$}
      - {load: snakecase}

In this case you can't use prefixes, there is no prefixes, so specify exact function names and const definitions. E.g.

- {action: accept, from: "^make_strips$"}
- {action: accept, from: "^ list_forward$"}
- {action: accept, from: "^ list_phy_toc$"}
...

from c-for-go.

5k3105 avatar 5k3105 commented on August 16, 2024

Sorry and thanks for the help.

Error:

  processing dexapi.yml ⠋[ERR] DexApi.h:37:14: unexpected identifier set_work_dir, expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]

header:

// -*- C++ -*-
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

//#define __cplusplus


#if !defined DexApi_h
#    define DexApi_h

typedef enum { eStopped=0, eTransition=1, eRunning=2 }STATES_E;
 
typedef enum { no_error  = 0,
               not_ready = -1,
               no_data   = -2,
               no_toc    = -3
} ERRORS_E;

enum {
   eMAX_API_VERSION=40  
};

#define DEX_EXP __declspec(dllexport)
#define DEX_IMP __declspec(dllimport)

#define API_SOURCE 1            // 1 for DLL; 0 for application
#if API_SOURCE==1
#define  DEX_API DEX_EXP
#else
#define  DEX_API DEX_IMP
#endif

#ifdef __cplusplus
extern "C" {
#endif
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API set_work_dir( const char *pName);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API set_batch_mode( int mode);
  
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API set_bin_filename( const char *pName);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API set_project_name(const char *pName);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API get_dll_version(char *pName, int size);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_run_state();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_delayed_result();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_frame_count();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_EXP get_shot_rate();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_1pps_count();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_strip_count();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API copy_ssd();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API make_strips();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API make_strip( int choice);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API get_section_pkts(int first, int last);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API list_forward();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API make_df3();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int DEX_API list_phy_toc();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_API get_phy_info( int *pArray, int num_ints );

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DEX_EXP get_reader_progress( int *pArray, int num_ints );

#ifdef __cplusplus
}
#endif

#endif // DexApi.h

yaml:

--- 
GENERATOR: 
  PackageName: dexapi
  PackageDescription: "Package dexapi provides Go bindings for Dex Tools 2.23 for IWR3 decode to DF3"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  Includes: ["DexApi.h"]

  Defines:
    DexApi_h: 1
    
PARSER: 
  SourcesPaths: ["DexApi.h"]

  Rules: 
    global:
      - {action: accept, from: "^set_work_dir$"}
      - {action: accept, from: "^make_strips$"}
      - {action: accept, from: "^list_forward$"}
      - {action: accept, from: "^list_phy_toc$"}
    
    

from c-for-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.