Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous reference 'beta' when compiling with gnu g++ #8

Open
dorseyb opened this issue Feb 14, 2024 · 2 comments
Open

Ambiguous reference 'beta' when compiling with gnu g++ #8

dorseyb opened this issue Feb 14, 2024 · 2 comments

Comments

@dorseyb
Copy link

dorseyb commented Feb 14, 2024

When compiling on Mac Studio (M1 ultra, OS X 14.2.1) using g++ installed via Homebrew, there seems to be an ambiguous reference involving the global 'beta' variable and a function in one of the libraries. I know very little about compiling code but I was able to get it to compile by changing the name of the variable ('beta' to 'betaN') in all files where it occurs.

There are also a number of warnings that may or may not need addressing. Below is the output from the failed compilation. The warnings persisted on the successful compilation. Happy to provide any other info if I can.

/opt/homebrew/opt/gcc/bin/g++-13 -fopenmp -c start.cpp errors.cpp
In file included from global_defs.h:39,
from start.cpp:30:
MersenneTwister.h: In member function 'MTRand::uint32 MTRand::randInt()':
MersenneTwister.h:222:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
222 | register uint32 s1;
| ^~
MersenneTwister.h: In member function 'void MTRand::seed(uint32*, uint32)':
MersenneTwister.h:267:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
267 | register int i = 1;
| ^
MersenneTwister.h:268:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
268 | register uint32 j = 0;
| ^
MersenneTwister.h:269:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
269 | register int k = ( N > seedLength ? N : seedLength );
| ^
MersenneTwister.h: In member function 'void MTRand::seed()':
MersenneTwister.h:313:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
313 | register uint32 *s = bigSeed;
| ^
MersenneTwister.h:314:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
314 | register int i = N;
| ^
MersenneTwister.h:315:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
315 | register bool success = true;
| ^~~~~~~
MersenneTwister.h: In member function 'void MTRand::initialize(uint32)':
MersenneTwister.h:337:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
337 | register uint32 *s = state;
| ^
MersenneTwister.h:338:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
338 | register uint32 *r = state;
| ^
MersenneTwister.h:339:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
339 | register int i = 1;
| ^
MersenneTwister.h: In member function 'void MTRand::reload()':
MersenneTwister.h:353:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
353 | register uint32 p = state;
| ^
MersenneTwister.h:354:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
354 | register int i;
| ^
MersenneTwister.h: In member function 'void MTRand::save(uint32
) const':
MersenneTwister.h:393:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
393 | register uint32 sa = saveArray;
| ^~
MersenneTwister.h:394:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
394 | register const uint32 s = state;
| ^
MersenneTwister.h:395:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
395 | register int i = N;
| ^
MersenneTwister.h: In member function 'void MTRand::load(uint32
)':
MersenneTwister.h:403:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
403 | register uint32 s = state;
| ^
MersenneTwister.h:404:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
404 | register uint32 la = loadArray;
| ^~
MersenneTwister.h:405:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
405 | register int i = N;
| ^
start.cpp: In function 'int main(int, char
)':
start.cpp:489:9: error: reference to 'beta' is ambiguous
489 | beta[j]=log(0.1/(1-0.1));
| ^~~~
In file included from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/cmath:3699,
from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/math.h:36,
from start.cpp:23:
/opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/specfun.h:341:5: note: candidates are: 'template<class _Tpa, class _Tpb> typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::beta(_Tpa, _Tpb)'
341 | beta(_Tpa __a, _Tpb __b)
| ^~~~
global_defs.h:92:14: note: 'double
beta'
92 | GLOB double beta; // vector of population effect
| ^~~~
start.cpp:523:38: error: reference to 'beta' is ambiguous
523 | theta=exp(-(alpha[i]+beta[j]));
| ^~~~
/opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/specfun.h:341:5: note: candidates are: 'template<class _Tpa, class _Tpb> typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::beta(_Tpa, _Tpb)'
341 | beta(_Tpa __a, _Tpb __b)
| ^~~~
global_defs.h:92:14: note: 'double
beta'
92 | GLOB double beta; // vector of population effect
| ^~~~
start.cpp:1052:57: error: reference to 'beta' is ambiguous
1052 | cur_fst[i]+=1/(1+exp(-(alpha[i]+beta[j])));
| ^~~~
/opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/specfun.h:341:5: note: candidates are: 'template<class _Tpa, class _Tpb> typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::beta(_Tpa, _Tpb)'
341 | beta(_Tpa __a, _Tpb __b)
| ^~~~
global_defs.h:92:14: note: 'double
beta'
92 | GLOB double *beta; // vector of population effect
| ^~~~
make: *** [start.o] Error 1

@vasotola
Copy link

Hi, could you be more specific of which files and variables you did the beta changing for? I am running into the same issue, and tried what you did and it did not work. Thanks!

@dorseyb
Copy link
Author

dorseyb commented Mar 15, 2024

Hi,
I went through each source file and did a text search for 'beta'. For each of the hits, I changed 'beta' to 'betaN'. This variable is not in every file, but it is in multiple so just check each one. I don't remember which, but one of the libraries called by the program has a beta distribution function and these two uses of 'beta' were apparently causing the problem. So, renaming one gets rid of the ambiguous reference.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants