Strange behaviour with C-Includes

Ok here is the Smaller Version … does not even need a container to replicate the Behaviour
Tested on a Mac (and a Ubuntu Container)

Darwin desktop-gv38ou7.uniserv.de 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

go version go1.14.4 darwin/amd64

We need 2 Files

File demo.go

package main

// #include <stdio.h>
// #include “demo.h”
// void answer(){
// fprintf(stderr,“the answer to life universe and everything is: %d\n”,ANSWER);
// }
import “C”

func main() {
C.answer();
}

and a File demo.h

#define ANSWER 43

Now running the Programm using go run demo.go will give me the output

the answer to life universe and everything is: 43

Changing the Value ANSWER in demo.h to 42 and running it again with go run demo.go does NOT give me back the Value 42, it still gives me back

the answer to life universe and everything is: 43

but should be “42” … I even can change the File to invalid C-Code and I still get the Value

the answer to life universe and everything is: 43

Am I getting something wrong ?

As you haven’t said how you actually build the container, it seems to be correct, that changes on the host do not affect the container in any way.

I mounted the Filesystem using -v /Users/graf/DEV/:/root/develop and did work on these files in the Container … but I was able to replicate the behaviour without the usage of a Contianer … (see above)

Ahh seems that I have to clean the cache using

go clean -cache

Thanx

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.