LNK2019 error from using a function pointer to core.bitop functions?

Matthew Gamble via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 15 20:24:52 PDT 2015


This member function of my struct uses a function pointer btx. 
When the line declaring the function pointer is present I get a 
LNK2019 error: unresolved external symbol.

bool opIndexAssign(bool value, size_t[2] inds)
{
	int function(size_t*, size_t) btx = (value) ? &bts : &btr; // 
error is here
		
         // other stuff here
		
	for (size_t i = startBitInd; i < startWordBitDone; ++i) 
btx(&bitArray[startWord], i);
		
         // other stuff here

	if (startWord != stopWord) for (size_t i = 0; i < stopBitInd; 
++i) btx(&bitArray[stopWord], i);
	return value;
}


However, when I don't use the function pointer and instead call 
bts directly (as outlined below, the program compiles and links 
just fine.

bool opIndexAssign(bool value, size_t[2] inds)
{
			
         // other stuff here
		
	for (size_t i = startBitInd; i < startWordBitDone; ++i) 
bts(&bitArray[startWord], i);
		
         // other stuff here

	if (startWord != stopWord) for (size_t i = 0; i < stopBitInd; 
++i) bts(&bitArray[stopWord], i);
	return value;
}

Any ideas how to fix this behavior? I was trying to use the 
function pointer so I wouldn't need to write essentially the same 
code block replacing bts with btr in if and else blocks

Any help would be appreciated. Thanks


More information about the Digitalmars-d-learn mailing list