# Log2() missing in MSVC v16

**URL:** <https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687>\
**Category:** GNU Radio\
**Created:** [October 22, 2014, 3:18pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687 "2014-10-22T15:18:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 22, 2014, 3:18pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/1 "2014-10-22T15:18:42Z")

</div>

Hi again.

I finally was able to build most of GR using CMake and  
the generated “Visual Studio 2010” gnuradio.sln file. Since I’m  
not sure if this platform is supported or not, it may be a futile  
attempt.

I patched cmake/msvc/config.h since I figured that was the active one.  
IMHO it’s confusing that ‘volk\cmake\msvc\config.h’ seems to include  
almost the same stuff.

Well, volk now uses the log2() function which my MSVC v16  
doesn’t have. And multiply\_matrix\_ff\_impl.cc etc. uses these  
ISO-646 “keywords” like ‘not’, ‘and’ etc. I solved these errors by  
patching cmake/msvc/config.h like so:

@@ -29,6 +29,16 @@  
static inline double rint(double x){return (x \> 0.0)? floor(x + 0.5) :  
ceil(x - 0.5);}  
static inline float rintf(float x){return (x \> 0.0f)? floorf(x + 0.5f)  
: ceilf(x - 0.5f);}

+static inline double log2 (double x)  
+{

- return log ((double)x) / log (2.0F);  
+}
- 

+// Use of ISO-646 keyword (‘not’, ‘and’ etc. needs this header.  
+#ifdef \_\_cplusplus  
+#include   
+#endif  
+

(the cast in log2() was need to resolve any C++ ambiguty).  
Not sure if this hurts if VC 2012+ already have log2() in it’s \<math.h\>.

BTW.

Here is how I used VC 2010 Express to build:  
cmake -G “Visual Studio 10 2010”  
msbuild -nologo -p:Configuration=Release -fileLogger  
-fileLoggerParameter:Summary;Verbosity=minimal;LogFile=gnuradio-build.log  
gnuradio.sln

Anybody else having success with VC 2010? Or are you Windows users  
(Ettus?) using VS 2012 only? Seems like Win-XP is unsupported since I  
get  
a call to the non-existant GetThreadId(). It’s in kernel32.dll, but on  
Vista+ only.

–gv

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [October 23, 2014, 2:27pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/2 "2014-10-23T14:27:32Z")

</div>

On 10/22/2014 03:16 PM, Gisle V. wrote:

> Well, volk now uses the log2() function which my MSVC v16  
> doesn’t have. And multiply\_matrix\_ff\_impl.cc etc. uses these ISO-646  
> “keywords” like ‘not’, ‘and’ etc. I solved these errors by patching  
> cmake/msvc/config.h like so:

Tom patched the nots, ors and ands a while back, at least on master. So  
you shouldn’t have to take care of those.

> @@ -29,6 +29,16 @@  
> static inline double rint(double x){return (x \> 0.0)? floor(x + 0.5) :  
> ceil(x - 0.5);}  
> static inline float rintf(float x){return (x \> 0.0f)? floorf(x + 0.5f) :  
> ceilf(x - 0.5f);}
> 
> +static inline double log2 (double x)  
> +{
> 
> - return log ((double)x) / log (2.0F);  
> +}

This might be useful, but I can’t say. However, please make this an  
issue on the issue tracker, or it’ll get lost.

Cheers,  
M

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [October 23, 2014, 3:51pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/3 "2014-10-23T15:51:27Z")

</div>

On Thu, Oct 23, 2014 at 8:26 AM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On 10/22/2014 03:16 PM, Gisle V. wrote:
> 
> > Well, volk now uses the log2() function which my MSVC v16  
> > doesn’t have. And multiply\_matrix\_ff\_impl.cc etc. uses these ISO-646  
> > “keywords” like ‘not’, ‘and’ etc. I solved these errors by patching  
> > cmake/msvc/config.h like so:
> 
> Tom patched the nots, ors and ands a while back, at least on master. So  
> you shouldn’t have to take care of those.

Looks like a missed to 'not’s in there 🙂 I’ll patch this soon.

> > +}
> 
> This might be useful, but I can’t say. However, please make this an  
> issue on the issue tracker, or it’ll get lost.
> 
> Cheers,  
> M

Also, considering that Windows XP is an unsupported operating system  
from  
Microsoft, we don’t have much of an incentive to track it or keep things  
updated there. If your patches are trivial and don’t bother anything  
else,  
then sure. But it looks like your patch here just shoves in the log2  
without regard for whether or not log2 actually exists on the system.  
There’s going to need to be a #if check around it. Perhaps Cmake can  
check  
for log2 and define a variable (HAVE\_LOG2 or something) for this.

Tom

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [October 23, 2014, 4:59pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/4 "2014-10-23T16:59:54Z")

</div>

On 10/23/2014 03:38 PM, Tom R. wrote:

> Looks like a missed to 'not’s in there 🙂 I’ll patch this soon.

Untie the nots?  
I shouldn’t be joking, probably being the person who put them in…

> ```
> M
> 
> ```
> 
> Also, considering that Windows XP is an unsupported operating system  
> from Microsoft, we don’t have much of an incentive to track it or keep  
> things updated there. If your patches are trivial and don’t bother  
> anything else, then sure. But it looks like your patch here just shoves  
> in the log2 without regard for whether or not log2 actually exists on  
> the system. There’s going to need to be a #if check around it. Perhaps  
> Cmake can check for log2 and define a variable (HAVE\_LOG2 or something)  
> for this.

Actually, I just now ran into this elsewhere – log2() is actually  
C++11, which we don’t officially support (although except for some  
MSVCs, this stuff is pretty much available everywhere). Gisle, if you  
could provide something like Tom suggested, that would be useful.

Cheers,  
Martin

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [October 23, 2014, 7:04pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/5 "2014-10-23T19:04:15Z")

</div>

“Tom R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Also, considering that Windows XP is an unsupported operating system from  
> Microsoft, we don’t have much of an incentive to track it or keep things  
> updated there.

There isn’t much in Gr that absolutely needs Win-Vista+. Except  
for GetThreadId() which I really have little idea why is needed. But  
this function could be emulated on pre-Vista.

> If your patches are trivial and don’t bother anything else,  
> then sure. But it looks like your patch here just shoves in the log2  
> without regard for whether or not log2 actually exists on the system.

According to:  
[log2 Function | Microsoft Learn](http://msdn.microsoft.com/en-us/library/hh308239(v=vs.110).aspx)

log2() is available in VC 2012 onwards. So an #ifdef could test  
for ‘\_MSC\_VER \<= 1600’ I believe.

–gv

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [October 23, 2014, 5:36pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/6 "2014-10-23T17:36:48Z")

</div>

* * *

Discuss-gnuradio mailing list  
removed\_email\_address@domain.invalid  
[https://lists.gnu.org/mailman/listinfo/discuss-gnuradio](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

---

<div class="post-metadata">

**Author:** ![Gisle\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b782af/32.png) [@Gisle\_V](https://www.ruby-forum.com/u/Gisle_V)\
**Post date:** [November 17, 2014, 11:35pm UTC](https://www.ruby-forum.com/t/log2-missing-in-msvc-v16/232687/7 "2014-11-17T23:35:46Z")

</div>

Hello Gisle,  
I made also a attempt with gnuradio 3.7.5.1 and MS vs2010 express. But  
without luck. Beside your reported problems I had issues with static  
declarations in some places which the Compiler rejected because they  
will be dllimported. These declarations are new in this Version - in  
3.6.5.1 they didn’t exist.  
BTW can you send me your build/CmakeCache.txt for Information.  
Thanks,  
Dietmar
