D.P. Leemon
D.P. Leemon

Reputation: 11

Cannot open include file 'rpcerr.h': No such file or directory

I was happily compiling and running source code today. Then I added a few lines to one of my modules, and suddenly Visual Studio 2012 refused to compile the code, with the error message:

error C1083: Cannot open include file: 'rpcerr.h': No such file or directory.

I'm not sure why the compiler suddenly needs to find rpcerr.h. I'm not doing anything I wasn't doing yesterday, but now I can't make the error go away.

I also have not been able to find rpcerr.h, myself. The reference is in rpc.h, which is part of the Visual Studio library. I'm guessing it got linked in because I included <windows.h>. But I don't know where I can find rpcerr.h, or what this file is supposed to do.

I would really like to go forward with this development. I'm guessing the code tried to compile rpcerr.h for a good reason, and that if I'm going to be using rpc.h for whatever reason this gets compiled into my source code, then I should get rpcerr.h as well. But trying to find it is sending me into a mobius loop.

Currently, the compiler is only complaining about rpcerr.h.

Upvotes: 1

Views: 1776

Answers (1)

Hans Passant
Hans Passant

Reputation: 942109

I'd better write this up, this is bound to happen again sooner or later. The <rpc.h> SDK file is stone cold old and dates back to the days that Microsoft supported writing code for an Apple Macintosh. It still supports it, there's an #include for rpcerr.h. But that file is no longer supplied, only rpcnterr.h is available.

You need to scan your source, or recently added #includes, for the a #define for MAC or _MAC, the one that Microsoft uses to select a Macintosh target. Using the editor's "Go To Definition" context menu command is the easiest way.

Or use this as a workaround:

#undef MAC
#undef _MAC
#include <rpc.h>

Or change the order of #includes. Beware that these workarounds might have side-effects, depending on how the other definition is used.

Upvotes: 2

Related Questions