Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

error: 'my_struct' does not name a type

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
keet
Guru
Guru
Posts: 580
Joined: Tue Sep 09, 2008 12:04 am

error: 'my_struct' does not name a type

  • Quote

Post by keet » Tue Nov 01, 2022 1:16 pm

Hello, might anyone be able to help with a C++ problem I'm encountering?

Hello, when I try to compile my C++ program, the compiler says, "error: 'S_Time' does not name a type." However, that struct is defined in a header file that I #include-d in the header file that the compiler cites in the error message.

Other files are using that struct with no problems.

This is the file that it's complaining about (not actual names):

Code: Select all

#ifndef INTEGRATION_H
#define INTEGRATION_H

#include "file.h"
#include "b_sort.h"
#include "p_weeks.h"
#include "s_times.h"

struct Service_B {
	S_Time s_time;
	int x {0};
	sys_days y;
};

vector<Service_B> make_sbs();

#endif
and then the s_times.h file where S_Time is defined:

Code: Select all

#ifndef S_TIMES_H
#define S_TIMES_H

#include "cs.h"
#include "c_web.h"
#include "c_file.h"

struct S_Time {
	Cs cs;
	string time;
	string id;
};

void print_s_times();
vector<S_Time> get_s_times_from_cm();

#endif
Thank you!
Top
mike155
Advocate
Advocate
Posts: 4438
Joined: Fri Sep 17, 2010 11:33 pm
Location: Frankfurt, Germany

  • Quote

Post by mike155 » Tue Nov 01, 2022 1:25 pm

Please take a look at: https://stackoverflow.com/questions/840 ... ame-a-type
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

Re: error: 'my_struct' does not name a type

  • Quote

Post by GDH-gentoo » Tue Nov 01, 2022 2:31 pm

keet wrote:Hello, when I try to compile my C++ program, the compiler says, "error: 'S_Time' does not name a type."
Which usage of name S_Time is it complaining about? The declaration of member s_time of class Service_B, the declaration of function get_s_times_from_cm(), or something else?
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
keet
Guru
Guru
Posts: 580
Joined: Tue Sep 09, 2008 12:04 am

  • Quote

Post by keet » Tue Nov 01, 2022 3:08 pm

mike155 wrote:Please take a look at: https://stackoverflow.com/questions/840 ... ame-a-type
I should have noted that the line it's saying has the error is not the one with the vector; it's this one:

Code: Select all

struct Service_B {
   S_Time s_time; 
Top
keet
Guru
Guru
Posts: 580
Joined: Tue Sep 09, 2008 12:04 am

Re: error: 'my_struct' does not name a type

  • Quote

Post by keet » Tue Nov 01, 2022 3:10 pm

GDH-gentoo wrote:
keet wrote:Hello, when I try to compile my C++ program, the compiler says, "error: 'S_Time' does not name a type."
Which usage of name S_Time is it complaining about? The declaration of member s_time of class Service_B, the declaration of function get_s_times_from_cm(), or something else?
Sorry, it's the part where I am declaring the Service_B struct/class.
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

Re: error: 'my_struct' does not name a type

  • Quote

Post by GDH-gentoo » Tue Nov 01, 2022 3:36 pm

keet wrote:Sorry, it's the part where I am declaring the Service_B struct/class.
Then, the definition of class S_Time somehow is not visible where member s_time is declared, possibly pointing at some problem in the included source files. Since you posted a modified version of them, I can't tell why exactly is that.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
mike155
Advocate
Advocate
Posts: 4438
Joined: Fri Sep 17, 2010 11:33 pm
Location: Frankfurt, Germany

  • Quote

Post by mike155 » Tue Nov 01, 2022 3:41 pm

So it's basically the code below that leads to an error?

Code: Select all

struct S_Time {
   int i;
};

struct Service_B {
   S_Time s_time;
   int x;
};

int main() {

}
Try:

Code: Select all

struct Service_B {
   struct S_Time s_time;
   int x;
};
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Tue Nov 01, 2022 3:55 pm

The struct keyword should not be needed in the declarations of members of Service_B, unless the name S_Time is also used here for something declared in global namespace scope that is not a type.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
Hu
Administrator
Administrator
Posts: 24385
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Nov 01, 2022 4:25 pm

keet: when you want help with a problem, please provide it in a form where we can reproduce the error you want to solve. If you want to rename members, that is fine, but what you give us should be a compiler input that you expect to work and that, if we fix the one problem about which you are asking, should work. In this case, several headers were not shown at all, and you trimmed the compiler error message to not tell which line it rejects.
Top
keet
Guru
Guru
Posts: 580
Joined: Tue Sep 09, 2008 12:04 am

  • Quote

Post by keet » Tue Nov 01, 2022 4:35 pm

Thank you for your help. It's working now. The forum post that mike155 linked to, even though it didn't fix the problem, did teach me not to put #using statements in header files. There were some circular dependencies that I fixed by moving the struct declaration and its related functions to a different file.
Top
Post Reply

10 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic