Advertisements

On 2006-11-29 06:42, Neo wrote:
> Hie,
> Can I put __FILE__ and __LINE__ macros inside the class function which
> may not be inline.

Since they are macros they are expanded by the pre-processor so whether
the functions are inline or not does not matter, it's the file and line
on which the code is written that is "returned", not where they are called.
> And
>
> void function()
> {
> classobject::LogInfo(...);
> }
>
> Internally LogInfo should log file name and line number. Here I dont
> want user to pass those macros and also dont want to use any macros.
> Is there any solution?

Do I understand you correctly in not wanting to pass the file and line
to the LogInfo()-function but would rather like it to know the line and
file magically in some way? Might work, depending on which filename and
line-number you want, as I said earlier, it's the filename and line-
number of the file where the code is written that is expanded.

Advertisements

Erik Wikström wrote:
> On 2006-11-29 06:42, Neo wrote:
> > Hie,
> > Can I put __FILE__ and __LINE__ macros inside the class function which
> > may not be inline.
>
> Since they are macros they are expanded by the pre-processor so whether
> the functions are inline or not does not matter, it's the file and line
> on which the code is written that is "returned", not where they are called.
>
> > And
> >
> > void function()
> > {
> > classobject::LogInfo(...);
> > }
> >
> > Internally LogInfo should log file name and line number. Here I dont
> > want user to pass those macros and also dont want to use any macros.
> > Is there any solution?
>
> Do I understand you correctly in not wanting to pass the file and line
> to the LogInfo()-function but would rather like it to know the line and
> file magically in some way? Might work, depending on which filename and
> line-number you want, as I said earlier, it's the filename and line-
> number of the file where the code is written that is expanded.
>
> --
> Erik Wikström

Erik Wikström wrote:
> On 2006-11-29 06:42, Neo wrote:
> > Hie,
> > Can I put __FILE__ and __LINE__ macros inside the class function which
> > may not be inline.
>
> Since they are macros they are expanded by the pre-processor so whether
> the functions are inline or not does not matter, it's the file and line
> on which the code is written that is "returned", not where they are called.
>
> > And
> >
> > void function()
> > {
> > classobject::LogInfo(...);
> > }
> >
> > Internally LogInfo should log file name and line number. Here I dont
> > want user to pass those macros and also dont want to use any macros.
> > Is there any solution?
>
> Do I understand you correctly in not wanting to pass the file and line
> to the LogInfo()-function but would rather like it to know the line and
> file magically in some way? Might work, depending on which filename and
> line-number you want, as I said earlier, it's the filename and line-
> number of the file where the code is written that is expanded.
>
> --
> Erik Wikström

Neo wrote:
>
> Erik Wikström wrote:
> > On 2006-11-29 06:42, Neo wrote:
> > > Hie,
> > > Can I put __FILE__ and __LINE__ macros inside the class function which
> > > may not be inline.
> >
> > Since they are macros they are expanded by the pre-processor so whether
> > the functions are inline or not does not matter, it's the file and line
> > on which the code is written that is "returned", not where they are called.
> >
> > > And
> > >
> > > void function()
> > > {
> > > classobject::LogInfo(...);
> > > }
> > >
> > > Internally LogInfo should log file name and line number. Here I dont
> > > want user to pass those macros and also dont want to use any macros.
> > > Is there any solution?
> >
> > Do I understand you correctly in not wanting to pass the file and line
> > to the LogInfo()-function but would rather like it to know the line and
> > file magically in some way? Might work, depending on which filename and
> > line-number you want, as I said earlier, it's the filename and line-
> > number of the file where the code is written that is expanded.
> >
> What you wrote is correct. So is there any way to do it?

Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!