Giter VIP home page Giter VIP logo

Comments (10)

lotodore avatar lotodore commented on July 24, 2024 2

I've added a pull request which fixes this issue.

from c-for-go.

bearsh avatar bearsh commented on July 24, 2024

I'm new to c-fo-go and I try to bring https://github.com/goonya/open62541-go up to date but I also see missing const definitions. surprisingly not all const/defines are missing but most.
maybe @lotodore has a clou as he's the author of c95ebd0

from c-for-go.

xlab avatar xlab commented on July 24, 2024

@lotodore we summon you :)

from c-for-go.

lotodore avatar lotodore commented on July 24, 2024

Thanks for testing the latest release! I'm really happy to receive some kind of feedback, as I wasn't sure whether everything is fine. The code I used to test migration to CCv4 only translates enums. I need to add one or more unit tests for defines, probably the CC tree changed with regards to defines. It may take a few days, however, as I'm really busy with a work project at the moment.
@yeahdongcn Is this related to the "replace" action from your configuration file or can the issue be reproduced just with the define without "replace"?

from c-for-go.

yeahdongcn avatar yeahdongcn commented on July 24, 2024

@lotodore Yes, enums translation works fine on my side too. I have tried to remove replace and this issue is still reproducible.

BTW, I'm using the following code to pin to the latest version of c-for-go and the config file hasn't been updated recently.

C_FOR_GO = $(shell pwd)/bin/c-for-go
.PHONY: c-for-go
c-for-go: ## Download c-for-go locally if necessary.
	$(call go-install-tool,$(C_FOR_GO),github.com/xlab/c-for-go@latest)

# go-install-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
ended

from c-for-go.

yeahdongcn avatar yeahdongcn commented on July 24, 2024

Thanks for fixing this issue! Tested against the latest commit, the defines are back.

One more change is introduced as follows. Do you think this should be considered as a new issue?

Source: abc.h

#ifndef ABC_H_
#define ABC_H_

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_MSC_VER)
    #ifdef ABC_EXPORT
        #define ABC_API __declspec(dllexport)
    #else
        #define ABC_API __declspec(dllimport)
    #endif
#else
    #define ABC_API __attribute__ ((visibility ("default")))
#endif

Generated: const.go

const (
    // H_ as defined in include/abc.h

    // API as defined in include/abc.h
    API = 0x5edf60

    ...
)

from c-for-go.

lotodore avatar lotodore commented on July 24, 2024

At first sight, I'm not sure whether the new issue is a bug. If you believe it is, I'd suggest that you post it separately.
The parser has improved with the update, so it will catch all definitions. If you include these definitions in your rules, they will be exported. ABC_API is to be included according to your rules, so at first sight I would say you need to exclude it if you do not want that.

from c-for-go.

yeahdongcn avatar yeahdongcn commented on July 24, 2024

Sounds reasonable. Let me close this issue first.

from c-for-go.

lotodore avatar lotodore commented on July 24, 2024

Thinking more about it, one might be able to filter these kind of definitions by checking whether they are "pointers", because these pointers cannot be translated to const in any meaningful way. I cannot promise, but feel free to open a new issue :-)

from c-for-go.

xlab avatar xlab commented on July 24, 2024

Agree, previously it wouldn't work at all, so we'd filter somethinging like that on the spec level

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.