Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:49:06+00:00 2026-06-13T22:49:06+00:00

Edit: Sigh, I feel like an idiot. I never had c++ file inclusion properly

  • 0

Edit:

Sigh, I feel like an idiot. I never had c++ file inclusion properly explained to me until months after I asked his question. Please refrain from commenting on exactly how flawed my setup was, I know perfectly well.

I have a multiple-file project containing many .h and .cpp files. One in particular, io_util.h, produces a bizarre series of errors. For the .h, which contains function declarations but no implementations, compiles perfectly, but in the .cpp, where the function bodies are, every function creates the following error:

   Multiple markers at this line
- first defined here
- multiple definition of 
 `<namespace>::<function name>(<args>)'

The file "io_util.cpp" is included only once in the project, CollectionBase.h. "io_util.h" is only included by "io_util.cpp"

Here are the two files:

.h:

/*
 * io_util.h
 */

#ifndef IO_UTIL_H_
#define IO_UTIL_H_

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>

#define IO_DEBUG(a) cout << #a << '=' << a << '\n'

#define CASE_SEP 32
#define NUM_CHAR_SEP 48

namespace std
{
    void getVar(int&, int);
    
    void getVar(double&, double);
    
    void getVar(unsigned&, unsigned);
    
    int get_num_digits(int);
    
    int get_digit(int, const int, const int);
    
    string value_of(int);
}

#endif /* IO_UTIL_H_ */

.cpp:

/*
 * io_util.cpp
 */
#ifndef IO_H_
#define IO_H_

#include "io_util.h"

namespace std
{

void getVar(int& i, int forbidden = NAN)
{
    string str;

    while(true)
    {
        getline(cin,str);

        if(str.find_first_not_of("-0123456789") != string::npos || !(stringstream(str) >> i))
        {
            cout << "invalid input.\n\n";
        }
        else if(i == forbidden)
        {
            cout << "illegal value.\n\n";
        }
        else
        {
            break;
        }
    }
}

void getVar(double& d, double forbidden = NAN)
{
    string str;

    while(true)
    {
        getline(cin,str);

        if(str.find_first_not_of("-.0123456789eE") != string::npos || !(stringstream(str) >> d))
        {
            cout << "invalid input.\n\n";
        }
        else if(d == forbidden)
        {
            cout << "illegal value.\n\n";
        }
        else
        {
            break;
        }
    }
}

void getVar(unsigned & u, unsigned forbidden = NAN)
{
    string str;

    while(true)
    {
        getline(cin,str);

        if(str.find_first_not_of("0123456789") != string::npos || !(stringstream(str) >> u))
        {
            cout << "invalid input.\n\n";
        }
        else if(u == forbidden)
        {
            cout << "illegal value.\n\n";
        }
        else
        {
            break;
        }
    }
}

int get_num_digits(int i)
{
    if(i < 0)
    {
        i = -i;
    }

    int result = 1;

    while(i > 10)
    {
        i /= 10;
        result++;
    }

    return result;
}

int get_digit(int i, const int num_digits, const int dig)
{
    if(num_digits < dig)
    {
        return 0;
    }

    const int dig_p10 = pow(10.0,num_digits - dig);

    i -= dig_p10 * round(i/dig_p10);

    if (dig < num_digits - 1)
    {
        i = round(i/int(pow(10.0,num_digits - dig - 1)));
    }

    return i;
}

string value_of(int i)
{
    string str;

    if (i < 0)
    {
        str += "-";
        i = -i;
    }

    const int num_dig = get_num_digits(i);

    for(int n = 0; n < num_dig; n++)
    {
        str += char(get_digit(i, num_dig, n) + NUM_CHAR_SEP);
    }

    return str;
}

}

#endif /*IO_H_*/

I have looked through many questions on this site regarding similar phenomena but none of them have helped.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:49:07+00:00Added an answer on June 13, 2026 at 10:49 pm

    First, io_util.cpp should be in the source file list of code files to be compiled. Everywhere in your project that needs the functionality contained therein should be including io_util.h, including CollectionBase.h. Do not #include .cpp files in anything (i.e. no #include “io_util.cpp” allowed).

    Second, your io_util.h header declares functions within the std namespace (which is also a no-no) called getVar(). The default parameter values for the trailing parameters belong there; not in the io_util.cpp file.

    Fixing both of those should get you substantially further down the road.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Simplified question. Why on earth, the file written is garbage (binary serilized data)
[edit]sigh... the spam protection here isn't letting me post the links, so I guess
EDIT After staring at this for 2 days, I do see one issue. I
Edit: I would like to model a 1 to 0:1 relationship between User and
edit: change of question if my code is like this: <form name=login action=https://login.extremebb.net/login method=post
EDIT The question was finding the divisors of numbers like 1,3,6,10,15 which follows n*(n+1)/2
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: Sorry, I should've searched more before I asked, because I've found a solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.