header-files

Intellisense in header files

I just right now "migrated" from C# to C++/CLR. First I was annoyed, that I had to write all class' declarations twice (into .h and .cpp). Then I figured out, that I could place the code also into the h-files - it compiles at least. Well, I deleted all cpp's of my classes and now I realized, VS won't give me any Intellisense when I work ...

When to put C++ function in header file

I've been looking at Boost and various other C++ libraries. The vast majority of Boost is implemented in header files. My question is: under what conditions do you do a header-only implementation (like Boost) or also include a .cpp file? ...

Why do I see THROW in a C library?

When I do: less /usr/include/stdio.h (which is only a C library - nothing to do with C++) I see __THROW after quite a few function declarations. Also, comments above a few functions say that 'This function is a possible cancellation point and therefore not marked with __THROW' What is all this for? throw is meant to be for exception ha...

How to use references, avoid header bloat, and delay initialization?

I was browsing for an alternative to using so many shared_ptrs, and found an excellent reply in a comment section: Do you really need shared ownership? If you stop and think for a few minutes, I'm sure you can pinpoint one owner of the object, and a number of users of it, that will only ever use it during the owner's lifeti...

Declaring STL Data Structures such as Vector in the .h

I am trying to declare a private Data Structure such as the Vector in my C++ header file which I want to eventually use within the method implementation of my .cpp. An example would be my header "SomeClass.h" where I have: class SomeClass { private: Vector<T> myVector; public: void AddTtoMyVector(T add); } And in my .cpp whic...

Windows <sys/file.h> equivalent

Is there a Win32 equivalent to the linux header file? I'm working on a Linux to Windows port (and my first time doing so) and it's failing on this file. ...

C++ include header conventions

Suppose I have a file X.h which defines a class X, whose methods are implemented in X.cc. The file X.h includes a file Y.h because it needs Y to define class X. In X.cc, we can refer to Y because X.h has already included Y.h. Should I still include Y.h in X.cc ? I understand that I don't need to and I can depend on header guards to pr...

fatal error C1014: too many include files : depth = 1024

I have no idea what this means. But here is the code that it supposely is happening in. //======================================================================================= // d3dApp.cpp by Frank Luna (C) 2008 All Rights Reserved. //======================================================================================= #include "d...

Splitting Code into Headers/Source files

I took the following code from the examples page on Asio class tcp_connection : public boost::enable_shared_from_this<tcp_connection> { public: typedef boost::shared_ptr<tcp_connection> pointer; static pointer create(boost::asio::io_service& io_service) { return pointer(new tcp_connection(io_service)); } tcp::socket&...

using macro defined in header files

I have a macro definition in header file like this: // header.h ARRAY_SZ(a) = ((int) sizeof(a)/sizeof(a[0])); This is defined in some header file, which includes some more header files. Now, i need to use this macro in some source file that has no other reason to include header.h or any other header files included in header.h, so sho...

Is this too much code for a header only library?

It seems like I had to inline quite a bit of code here. I'm wondering if it's bad design practice to leave this entirely in a header file like this: #include <list> #include <string> #include <boost/noncopyable.hpp> #include <boost/make_shared.hpp> #include <boost/iterator/iterator_facade.hpp> #include <Windows.h> #include "../Exception...

#import <FTUtils/FTAnimation.h> returns "No such file or directory exists error"

Anyone out there using the FTUtils library for iPhone development? Following the instructions here BUT getting an exception when I: #import <FTUtils/FTAnimation.h> The funny thing is, I can import every other header file BUT this one. Any ideas? ...

How to find out how namespace got polluted?

Consider the following little piece of code: // all of these include other headers, lots of code: #include "myheader1.h" #include "myheader2.h" #include <string> void foo() { string s("hello world"); // oh no, why does this compile?? } This compiles, so obviously some of the recursively included header files has a using namespace...

Visual studio: automatically update C++ cpp/header file when the other is changed?

For example, if I change the signature in a function in either the header or the cpp, I'd like it to automatically change in the other one. If I add a new function in either, it should appear in both. If I delete a function, it could probably comment out the other one. Manually having to duplicate one's changes seems silly. Some people ...

Access reading error when using class member variable

Hi, I have a class with private member variables declared in a header file. In my constructor, I pass in some filenames and create other objects using those names. This works fine. When I try to add another member variable, however, and initialize it in the constructor, I get an access reading violation. I sent the code to someone else ...

Is it bad practice to use a C header instead of its C++ equivalent in C++ (e.g. stdio.h instead of cstdio)?

It seems that a lot of people include example.h instead of cexample in their C++ code. I know that everything in the C++ versions is declared in namespace std, but I'm not aware of any other differences. So why do people use the C headers, and is it okay to do so? ...

Basic question on c++ header file inclusion ?

What are the differences between below 3 programs ?. Is <iostream> a header file or C++ standard library ? 1. #include<iostream> using namespace std; int main() { return 0; } 2. #include<iostream> int main() { return 0; } 3. #include<iostream.h> int main() { return 0; } Thanks in advance. ...

How to resolve include file names conflicts in GCC?

I have two header files named string.h in different libraries, they are conflicted with each other and even conflicted with standard C include file of the same name. There is no need to use any string.h except standard one, but I need to include libraries headers paths in GCC search path. Currently I use something like -I /usr/local/inc...

Is Valid IMAGE_DOS_SIGNATURE

I want to check a file has a valid IMAGE_DOS_SIGNATURE (MZ) function isMZ(FileName : String) : boolean; var Signature: Word; fexe: TFileStream; begin result:=false; try fexe := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); fexe.ReadBuffer(Signature, SizeOf(Signature)); if Signature = $5A4D { 'MZ' } then result:=...

ISO C++ forbids declaration of 'Stack" with no type

I have setup the following header file to create a Stack which uses an Array. I get the following at line 7: error: ISO C++ forbids declaration of 'Stack" with no type. I thought the type was the input value. Appreciate your help. Thank you. #ifndef ARRAYSTACKER_H_INCLUDED #define ARRAYSTACKER_H_INCLUDED // ArrayStacker.h: ...