Piotr Chojnacki
Piotr Chojnacki

Reputation: 6867

Is it good practice to have each typedef in separate file?

I've read somewhere, that it's good to have each typedef in separate file, but it wasn't even explained.

For example like this:

#ifndef _MYTYPEDEF_H
#define _MYTYPEDEF_H
#pragma once

#include <iostream>

typedef std::pair<unsigned short, int>  my_typedef;

#endif //_MYTYPEDEF_H

But I think it will be a mess if I have for example 50 typedefs in my project, so there would be 50 files just for them.

Upvotes: 2

Views: 201

Answers (1)

Alok Save
Alok Save

Reputation: 206566

This only obfuscates the code and confuses the one who maintains(which is not usually the one who invents such fancy ideas) it.
This is only good(if at all) for the developer who only sees single TUs during development but not for the one who maintains it and sees the entire code base post development.
Please don't do it at all.

Upvotes: 6

Related Questions