• Create Account

# Nullptr over-defined all the sudden (wtf?)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

### #1Juliean  GDNet+   -  Reputation: 5004

Like
0Likes
Like

Posted 23 September 2013 - 01:21 PM

Hello,

I've just been back from my summer home to my studend accomodation. Now, when trying to compile my engine here after cloning it from GIT, I've encountered one specific error:

1>c:\acclimate engine\repo\acclimate\dx11\render\..\..\Render\StateGroup.h(54): error C2664: 'acl::dx11::BindRenderTargets::BindRenderTargets(const acl::dx11::BindRenderTargets &)' : cannot convert parameter 4 from 'int' to 'const acl::dx11::d3d::DepthBuffer *' (DX11\Render\Stage.cpp)
1>          Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast


in this line:

			const d3d::Texture* pTextures[] = {nullptr};


Now, I'd probably searched some time, but I've noticed that the nullptr in this instance was painted violet instead of blue - so it was in the rest of the file, as well as the rest of the project! Now the issue appeared to me - nullptr was defined 0, which causes the template to deduce the wrong type for the last parameter (heh, thats why you should use them, I did it for convienince but seems to pay of).

Now, regardless of that the issue can "easily" be solved by adding an #undef nullptr to this file and all other files that possibly use it... how come this happening? At my laptop, I don't have that problem. I just compiled it not 1 hour ago, same commit. I'm using the same compiler, too - VS2012 with CTP - and I'm not using any external libaries other than the DirectX-sdk - 2010-version, on both PCs. I can hardly track where it comes from, too, since unless I undef, exluding specific files will take ages to make any difference for the markup. It also seem to affect almost the entire code, so I'm not sure.

Well, do you have any idea where this could come from?

### #2ApochPiQ  Moderators   -  Reputation: 18946

Like
1Likes
Like

Posted 23 September 2013 - 02:53 PM

Right click -> Go to Definition. Should show you where the macro originated.
Wielder of the Sacred Wands

### #3Juliean  GDNet+   -  Reputation: 5004

Like
0Likes
Like

Posted 23 September 2013 - 03:32 PM

Unfortunately, "Go to definition" (as well as all other options near that, except for "go to header") are grayed out. It doesn't even show me the definition if I hover over it, so its really weird. I think the only logical solution would be that it was defined in the directx-sdk... any idea if dx does that/did that at some point?

EDIT: Appearently, at least when searching the SDK include dir for "nullptr" in notepad++, it doesn't show any hit. More ideas where this could come from? My version of VS here is german, the other one english, but both have the SP1 installed, I'm really out of ideas.

Edited by Juliean, 23 September 2013 - 03:35 PM.

### #4Erik Rufelt  Crossbones+   -  Reputation: 5514

Like
2Likes
Like

Posted 23 September 2013 - 03:41 PM

It says parameter 4 but it seems there aren't 4 parameters in the function call?

Perhaps the error is something completely different. Try rebuild all or checking out the code anew into a different directory and building that, perhaps there's something cached from an old version.

### #5Juliean  GDNet+   -  Reputation: 5004

Like
0Likes
Like

Posted 23 September 2013 - 03:53 PM

It says parameter 4 but it seems there aren't 4 parameters in the function call?

Perhaps the error is something completely different. Try rebuild all or checking out the code anew into a different directory and building that, perhaps there's something cached from an old version.

Oups, in that matter, I should've posted the function definition:

template<typename S, typename... Args>
{
}


Variadic templates, and I don't know if its a bug of the CTP, but it starts couting "S" as 1, and the third parameter is then the fourth. And its definately due to this, like I said, if I add

#undef nullptr


at the top of the file, it works. Also if I specify a pointer to the expected object manually to nullptr and pass it in. Thats why nullptr is so cool for (variadic) templates, it auto-deduces the type, where NULL/0 will make out "Int" (unless its typedef'd to latter, lol). Then again, I've just been pulling hunders of commits from over 2-3 months into a local repo that I've been working on the last 3-4 months before, so it shouldn't hurt to give rebuilding & cleaning a try...

Nope, as I expected, didn't work eigther. Thanks still for the input, any more ideas however?

### #6ApochPiQ  Moderators   -  Reputation: 18946

Like
2Likes
Like

Posted 23 September 2013 - 05:14 PM

There should be a compiler option which lets you output the text seen after preprocessing. Compile the broken .cpp file with that option and look at the preprocessor output to see where the macro is being introduced. It should be easy from the surrounding context to deduce the origin.

Also, make sure it isn't a project (or file) specific macro defined on the compiler command line (vs. an actual #define).

Wielder of the Sacred Wands

### #7King Mir  Members   -  Reputation: 2250

Like
0Likes
Like

Posted 23 September 2013 - 06:10 PM

I think the easiest way to narrow the problem is to get a list of dependancies for the .o file you attempt to generate (or do generate if you use a file without the compile error, but still have nullptr as a macro). Then seach those for some variant of "#define nullptr".

Unfortunately, Windows doesn't provide good tools to do that..There probably is a way to get msvc to output the dependancy list, but searching them isn't trivial. It's why I like to use Cygwin. Getting it just to solve this problem is overkill (though you might consider g, but you can get a standalone "grep" application for windows. Or you can try to use windows and msvs's dificient tools for looking through files.

### #8Ravyne  GDNet+   -  Reputation: 12253

Like
0Likes
Like

Posted 23 September 2013 - 06:26 PM

It says parameter 4 but it seems there aren't 4 parameters in the function call?

Perhaps the error is something completely different. Try rebuild all or checking out the code anew into a different directory and building that, perhaps there's something cached from an old version.

Looks like a member function, so the first parameter is "this" which pushes the others out one position, but it doesn't appear in the args list.

throw table_exception("(ノ ゜Д゜)ノ ︵ ┻━┻");

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS