GLEW - Visual Studio Intellisense not showing complete function Signatures - visual-studio-2017

Recently, I have been learning OpenGL using GLEW. For this, I am using visual studio community IDE. For some reason, the visual studio intellisense doesn't show the complete function signature, when I hover over any function defined in glew, it only shows the macro defined in the glew.h, instead of the complete function definition.
For example, if i hover over glVertexAttribPointer(), it shows:
#define glVertexAttribPointer GLEW_GET_FUN(_glewVertexAttribPointer)
.
How do I get the intellisense to show the complete function signature? Thanks in advance

It won't show normally by hovering over the function name because it's just a macro define, and not a function itself. For example glVertexAttribPointer is defined as:
#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer)
__glewVertexAttribPointer is a typedef hidden behind another macro define of PFNGLVERTEXATTRIBPOINTERPROC, which is defined as:
typedef void(__stdcall *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)
With that many levels of indirection it's not surprising that the IDE struggles to treat this as just an ordinary function and give you the signature. But, at least in my Visual Studio 2017 Community it's simply enough to type glVertexAttribPointer and then as soon you open the bracket the function signature will appear. It will also show when typing a comma when separating arguments. This is what it looks like in my Visual Studio as soon as I open the bracket:
It comes up with a really handy list of all the arguments, and makes bold the argument that you are currently typing. Hope that helps.

Related

Is SetDlgItemDouble a C++ Function?

I was looking at using SetDlgItemInt and out of curiosity I changed it to SetDlgItemDouble to see if this was also a function.
SetDlgItemDouble has been recognised as a function and when I hover over it, it displays BOOL SetDlgItemDouble(HWND hDlg, int id, double d) but when I go to compile it gives me the error: error C3861: 'SetDlgItemDouble': identifier not found, even with argument-dependent lookup.
I've googled the term SetDlgItemDouble and it gives me a few links mainly in a far east language but nothing directly with MSDN and also searching this site nothing comes back.
So is it a function? If so, how do I use it with visual c++ 2003?
SetDlgItemDouble is not a standard C++ function: i.e. a standards compliant C++ compiler is not required to implement it.
But there's nothing stopping you from implementing it. Or a 3rd party library for that matter.
Your IDE is probably configured to think that the function exists, even if you don't have an explicit #include to the relevant file. Visual Studio does tend to do this (especially for standard C++ library functions that you haven't necessarily #included), in order to attempt to be helpful.
SetDlgItemDouble is not avaialble in MFC or win32. You can try using SetDlgItemInt (or) SetDlgItemText in visual c++. If the intention is to display a double value in any Dialog control, you can use SetDlgItemText and display that value as a string in your Dialog.

How to get autocompletion coding support writing winapi c++

I have been writing Java for a long time using Eclipse, now trying to switch to C++ in Visual Studio. From Eclipse/Java I know such auto-complete features: I write
bar = Foo.valueOf(x);
bar.doSomething(y, z);
and Eclipse offers me both to import whatever Foo I might mean, and declare bar as local variable, field, or parameter. Or create the function doSomething() with the appropriate signature, auto-adding missing imports to Foo. I am missing a corresponding feature on Visual Studio 2015, which does for example
add the corresponding #include and #pragma comment(lib, statements,
add these statements in a clear order, so that they work as expected (something like organize imports),
add namespace statements
declare variables, fields, and parameters on click/keypress
create function bodies, adding the corresponding foreward declarations to the respective header files, adding missing includes required by the declaration
…
The only things that I found so far is the “add class” dialog. When writing an unknown function name, right clicking and choosing “quick actions and refactorings” → Create declaration / definition, a window opens with the text
int main(int argc, char * argv[]);
but it does not create a definition for that function.
Are there some better “save me typing work” functions available in Visual Studio 15, and if yes, how can I benefit from them? Is there another way I could go, such as writing the C++ program (Windows API) in an other IDE (are there any for Winapi C++ which do better?)
Resharper by JetBrains does what you are asking for more or less. It will notice an error in your code, whether it being that something wasn't fully initialized, or something that you needed to include, or a host of other things.
It is not free though, but you can try it on a 30 day trial.
I don't know of an IDE that supports winapi functions like you're asking though. I think you'll just have to pick your favorite IDE and get used to it.

Error C2668 in bind while porting from VS2008 to VS2013

I'm trying to port my code from VS2008 to VS2013 and I'm getting some errors with std::bind.
The errors say error C2668: 'bind' : ambiguous call to overloaded function.
Here's some code:
// Relevant prototypes:
class CLineaPlanta:public SomeBase { /*...*/ };
int SomeBase::TipoLinea()const;
void SomeBase::TipoLinea(int val);
// function paramater: const std::shared_ptr<CLineaPlanta>& lineasBuscar
// function parameter: int tipoLinea;
std::shared_ptr<CLineaPlanta> lineas;
std::remove_copy_if(lineasBuscar.begin(), lineasBuscar.end(),
std::back_inserter(lineas),
bind(std::not_equal_to<int>(), bind(&CLineaPlanta::TipoLinea, _1), tipoLinea));
This code worked in Visual Studio 2008, but gives the mentioned error in Visual Studio 2013.
Obviously, the compiler's having a hard time figuring out which version of TipoLinea() I'm trying to call. If I rename the getter version to getTipoLinea, the error goes away.
Just in case it is relevant, SomeBase is non-abstract and derives from CObject (not really sure why) and from an interface not related to this part of the code.
Can anyone explain why VS2008 doesn't have any problem with this and how to prevent it (other than by renaming the function, of course)?
I have no idea why this code ever worked in VS2008. It was probably a consequence of 2008's bind being implemented as a macro-based variadics emulation where bind had several overloads for each number of arguments being passed, one of them expecting the first argument to be a pointer to member function with the same number of arguments. This would allow the compiler to disambiguate because you pass one bound argument to bind, so it knows the function argument must have one parameter.
In VS2013, true variadics are used, but this probably means that the type of the first argument is more generic and so the compiler can no longer disambiguate. To make this compile, you need to explicitly cast the member pointer:
std::remove_copy_if(lineasBuscar.begin(), lineasBuscar.end(),
std::back_inserter(lineas),
bind(std::not_equal_to<int>(),
bind(static_cast<int (SomeBase::*)() const>(&CLineaPlanta::TipoLinea),
_1),
tipoLinea));
But as Neil Kirk said, rewriting to a lambda is easier:
std::remove_copy_if(lineasBuscar.begin(), lineasBuscar.end(),
std::back_inserter(lineas),
[tipoLinea](const std::shared_ptr<CLineaPlanta>& linea) {
return linea->TipoLinea() != tipoLinea;
});

Prevent or generate warning for custom deprecations

I'm using C++11's static_assert to perform compile-time checks to prevent the use of insecure functions, and/or to provide feedback to the user when a new feature should be used and the relevant APIs are out of date (e.g. using std::strftime, std::to_string, etc.).
I want to force failure if any source code attempts to use outdated functions, but I need it to be totally cross-platform, and also bypass or workaround other 'helpers' such as Microsofts own deprecations.
I see I can use .sections when working with a gnu toolchain, which I can see the definition for in OpenBSD's cdefs.h (http://ninjalj.blogspot.co.uk/2011/11/your-own-linker-warnings-using-gnu.html) but I have nothing equivalent for Visual Studio.
For example, I can use the following code without a problem to prevent strcpy/strcat:
# define COMPILE_TIME_CHECK(expression, message) static_assert(expression, message)
# define GUARANTEE_FAILURE (0 == 1)
# define DISABLED_FUNCTIONS_MESSAGE_CSTRING "strcpy, strcat must be replaced with strlcpy and strlcat, respectively"
# define strcat COMPILE_TIME_CHECK(GUARANTEE_FAILURE, DISABLED_FUNCTIONS_MESSAGE_CSTRING);
it may be unclean but works; but the trouble is when attempting to do the same with others that don't play as nicely, such as ctime and localtime:
_CRT_INSECURE_DEPRECATE(localtime_s) static __inline struct tm * __CRTDECL localtime(const time_t * _Time)
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\time.inl(86): error C2059: syntax error : 'static_assert'
Is there a way I can block specific functions (warning or compile failure), while providing a message for what to use in their place, without conflict from gcc/visual studio in a suitable way? The CRT macros in visual studio do not prevent the above error with the aforementioned defines.
I'm not convinced something like __declspec(deprecated) int strcpy(char*,char*); (as noted here: C++ mark as deprecated) is going to always play ball, and is a lot more work & less descriptive than just setting a define for the function name.
you can use Disable:warning {#warning Code}

Visual Studio 2010 call stack window stripping template parameter types

I am currently writing and debugging a library that makes heavy use of templates as policy classes. Therefore, instantiated objects types are templates of template of...
Looking at the visual studio (2010) call stack window (as well as the output windows) makes it impossible to get the name of the function at a glance, because it lies at the end of three lines of signature.
The call stack window has several options to show/hide the parameter types/values, and other things, but none of these make the template types disappear. Ideally, I would like to be able to see the class name, stripped of all template parameters, and the function name (and revert to the current visualization to resolve ambiguities). Does this option exist?