Click here to Skip to main content
15,613,470 members
Articles / Programming Languages / C++
Posted 11 Nov 2016

Tagged as


5 bookmarked

Solving a C4183 Conundrum

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
11 Nov 2016CPOL1 min read
This tip describes how I resolved a C4183 compiler error emitted by the Visual C++ 2013 compiler.


In the course of implementing a class in a Visual C++ project, I encountered an error (documented as a warning) that I couldn't resolve by any of the methods discussed elsewhere. Thankfully, the solution that I developed, though slightly novel, is quite straightforward; move the typedef directly into the class definition header.


Having worked more in straight C than C++, and implemented C interfaces for most of my custom APIs, I was accustomed to declaring a structure and a pointer to one of its kind as follows.

typedef struct _PVT_SAFER_MUTEX
    HANDLE    ThisMutex ;
    DWORD    OwnerThread ;

It was a matter of habit to define structures and pointers to structures in this way in a header, include that header within another header, then declare functions that return the pointer type.


This works like a champ in straight C code.

Now comes a need to do something similar in the header that declares a class.

LPPVT_SAFER_MUTEX CHandleManager::GetMutexInfo ( SAFEER_MUTEX_HANDLE pHandle ) ;

Try this with the structure typedef in a separate header, and you get Compiler Warning (level 1) C4183, 'identifier': missing return type; assumed to be a member function returning 'int'.

Points of Interest

After about an hour of studying numerous articles about compiler warnning/error C4183, I decided to move the typedef from the external header into the header that declares the C++ class that contains methods that return pointers to the structure.

This worked.

On reflection, putting the typedef in the header that defines the class that uses it is a cleaner design, because it makes the class declaration more self-contained.


Friday, 11 November 2016 is the initial publication of this tip.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior)
United States United States
I deliver robust, clean, adaptable, future-ready applications that are properly documented for users and maintainers. I have deep knowledge in multiple technologies and broad familiarity with computer and software technologies of yesterday, today, and tomorrow.

While it isn't perceived as sexy, my focus has always been the back end of the application stack, where data arrives from a multitude of sources, and is converted into reports that express my interpretation of The Fundamental Principle of Tabular Reporting, and are the most visible aspect of the system to senior executives who approve the projects and sign the checks.

While I can design a front end, I prefer to work at the back end, getting data into the system from outside sources, such as other computers, electronic sensors, and so forth, and getting it out of the system, as reports to IDENTIFY and SOLVE problems.

When presented with a problem, I focus on identifying and solving the root problem for the long term.

Specialties: Design: Relational data base design, focusing on reporting; organization and presentation of large document collections such as MSDS libraries

Development: Powerful, imaginative utility programs and scripts for automated systems management and maintenance

Industries: Property management, Employee Health and Safety, Services

Languages: C#, C++, C, Python, VBA, Visual Basic, Perl, WinBatch, SQL, XML, HTML, Javascript

Outside Interests: Great music (mostly, but by no means limited to, classical), viewing and photographing sunsets and clouds, traveling by car on small country roads, attending museum exhibits (fine art, history, science, technology), long walks, especially where there is little or no motor traffic, reading, especially nonfiction and thoughtfully written, thought provoking science fiction

Comments and Discussions

QuestionDifference between C and C++ Pin
Joe Pizzi14-Nov-16 13:58
Joe Pizzi14-Nov-16 13:58 
AnswerRe: Difference between C and C++ Pin
David A. Gray1-Dec-16 20:11
David A. Gray1-Dec-16 20:11 
AnswerRe: Difference between C and C++ Pin
TheGreatAndPowerfulOz9-Dec-16 12:16
TheGreatAndPowerfulOz9-Dec-16 12:16 
SuggestionCode example.. Pin
PhilipOakley14-Nov-16 6:43
professionalPhilipOakley14-Nov-16 6:43 
GeneralRe: Code example.. Pin
David A. Gray1-Dec-16 20:06
David A. Gray1-Dec-16 20:06 
SuggestionRe: Code example.. Pin
PhilipOakley2-Dec-16 12:10
professionalPhilipOakley2-Dec-16 12:10 
GeneralRe: Code example.. Pin
David A. Gray3-Dec-16 19:16
David A. Gray3-Dec-16 19:16 
Your point is well taken, and I'll see what I can do about a revision. My immediate goal was to get the information out there, so that Google would index it, and it would be there for the next frustrated user (even if that happens to be me a year from now).

Also, as it turns out, the whole project may become the subject of a full article.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.