Jump to content
  • Advertisement
Sign in to follow this  
Juliean

Nullptr over-defined all the sudden (wtf?)

This topic is 2128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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}; 
			m_stageStates.Add<BindRenderTargets>(pTextures, 1, 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?

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites


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>
void StateGroup::Add(Args&& ... 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?

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!