LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2012, 04:15 AM   #1
skaushal_lk
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu, CentOS
Posts: 27

Rep: Reputation: 4
Question gcc warning for big struct or variable size


Hi friends,

I am wondering if there is any option in gcc to warn about big struct or variable sizes.

thanks in advance,
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-17-2012, 06:07 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You got a warning you don't want, or you want a warning you don't get?
 
Old 04-17-2012, 08:52 AM   #3
skaushal_lk
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu, CentOS
Posts: 27

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
You got a warning you don't want, or you want a warning you don't get?
Sorry i wasn't clear enough. Actually i want an option in gcc to flag the warning if a structure/variable/functions is too large or size is larger than user defined threshold size.
 
Old 04-17-2012, 08:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
maybe an assert can do this for you
 
Old 04-17-2012, 10:08 PM   #5
skaushal_lk
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu, CentOS
Posts: 27

Original Poster
Rep: Reputation: 4
I found the gcc options what i was looking for.

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
Quote:
-Wlarger-than=len
Warn whenever an object of larger than len bytes is defined.
-Wframe-larger-than=len
Warn if the size of a function frame is larger than len bytes. The computation done to determine the stack frame size is approximate and not conservative. The actual requirements may be somewhat greater than len even if you do not get a warning. In addition, any space allocated via alloca, variable-length arrays, or related constructs is not included by the compiler when determining whether or not to issue a warning
thanx every one.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc differences with C-struct initialization ta0kira Programming 2 08-09-2008 12:55 PM
GCC compile problem:struct A have a member variable which is just a struct type name? leon.zcom Programming 3 04-18-2008 04:40 PM
default array size for variable in gcc compiler mlaich Programming 13 01-04-2006 05:40 PM
About struct size Nerox Programming 3 02-07-2005 04:49 PM
g++ and wrong struct member addresses / struct size misreporting sonajiso Linux - General 5 05-22-2004 10:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration