# FreeBSD c++ and nullptr



## ahhyes (Apr 5, 2022)

Hi All,

Wondering if someone could offer some suggestions..

I am trying to port some software from Linux to FreeBSD. The software is a mix of C and C++, but mostly C++ and uses boost heavily.

When using the base clang compiler of FreeBSD it tries to always promote null to nullptr, which is giving me no end of headaches. If i install the gcc compiler from ports/packages the compiler does not give me all the grief.

This apparently is well known behavior for the clang compiler on FreeBSD (promoting null to nullptr) - is there a way to turn off that behavior in the base clang compiler on FreeBSD?


----------



## obsigna (Apr 5, 2022)

ahhyes said:


> Hi All,
> 
> Wondering if someone could offer some suggestions..
> 
> ...



My suggestion is to redefine NULL at a strategic place in your code:

```
#undef NULL
#define NULL 0
```


----------



## ahhyes (Apr 5, 2022)

I will try that thank you - I think I meant to post this over in userland dev on this forum, I am sure a moderator will be cranky at me - please move the thread


----------



## mark_j (Apr 5, 2022)

ahhyes said:


> Hi All,
> 
> Wondering if someone could offer some suggestions..
> 
> ...


For example?


----------



## ahhyes (Apr 5, 2022)

mark_j said:


> For example?


Its well known... Threads all over the net about this.

eg: https://github.com/coin-or/Cbc/issues/319
eg: https://github.com/PointCloudLibrary/pcl/issues/2349#issuecomment-417902124

And plenty of others who have run into the same issues.

It's been like this apparently since c++11


----------

