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

  • Home
  • SEARCH
  • 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 519087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:00:16+00:00 2026-05-13T08:00:16+00:00

I met some compilation error but do not know what the problem is. The

  • 0

I met some compilation error but do not know what the problem is. The code seems not use exception, but the error is about it.

//in misc.h:
char *basename(char *name); // line 94

// in misc.cc:
char *basename(char *name) {   // line 12
  char *result = name;  
  while(*name) {  
    if(*name == '/') result = name + 1;  
    name++;  
  }  
  return result;  
}  

Compilation error

g++ -pipe -W -Wall -fopenmp -ggdb3 -O2  -c -o misc.o ../../src/misc.cc  
../../src/misc.cc: In function ‘char* basename(char*)’:  
../../src/misc.cc:12: error: declaration of ‘char* basename(char*)’ throws different exceptions  
../../src/misc.h:94: error: from previous declaration ‘char* basename(char*) throw ()’  
make: *** [misc.o] Error 1

Does someone have some clue? Thanks and regards!


EDIT:
Files included in misc.h are

#include <iostream>  
#include <cmath>  
#include <fstream>  
#include <cfloat>  
#include <stdlib.h>  
#include <string.h>

EDIT:
in misc.i generated by -E option,

extern "C++" char *basename (char *__filename)  
     throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));  
extern "C++" __const char *basename (__const char *__filename)
     throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
# 640 "/usr/include/string.h" 3 4
# 1 "/usr/include/bits/string3.h" 1 3 4
# 23 "/usr/include/bits/string3.h" 3 4
extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters")));
# 48 "/usr/include/bits/string3.h" 3 4
extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) void * 
memcpy (void *__restrict __dest, __const void *__restrict __src, size_t __len) throw ()  

{  
  return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));  
}  
...  
# 641 "/usr/include/string.h" 2 3 4  
...
  • 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-05-13T08:00:16+00:00Added an answer on May 13, 2026 at 8:00 am

    You may be picking up the definition of basename() from libgen.h. On my OpenSUSE system, the version in libgen.h is defined with “throw ()” at the end (via the __THROW macro).

    One thing you can try is to tell gcc to only run the preprocessor stage by adding the -E flag and then search for basename to see what is being defined:

    g++ -pipe -W -Wall -fopenmp -ggdb3 -O2  -E -o misc.i ../../src/misc.cc  
    

    If that is happening, you’ll either need to drop the include of libgen.h, match the throw specifier or change the name of your function.

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

Sidebar

Ask A Question

Stats

  • Questions 269k
  • Answers 269k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use ADO.net to access cells in an excel… May 13, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer You can't even get an accurate measurement of velocity from… May 13, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer No. Even with regular requests to your app, the 30… May 13, 2026 at 1:21 pm

Related Questions

This is a syntax question. I was looking at some open source files and
I developed some WPF projects, but I met a very serious issue. As you
While testing some functions to convert strings between wchar_t and utf8 I met the
I met a wired problem for a web page in IE7/8. The page configured
While developing AJAX program, I met the design decision to make string I18N in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.