Skip to content

Commit c415af7

Browse files
author
Colin Robertson
authored
Steal shamelessly from Ray Chen for C3779 (#3584)
1 parent 159d9d9 commit c415af7

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
description: "Learn more about: Compiler Error C3779"
3+
title: "Compiler Error C3779"
4+
ms.date: 05/19/2021
5+
f1_keywords: ["C3779"]
6+
helpviewer_keywords: ["C3779"]
7+
---
8+
# Compiler Error C3779
9+
10+
> '*function*': a function that returns '*auto or decltype(auto)*' cannot be used before it is defined
11+
12+
The **`auto`** return type of the specified function call couldn't be deduced. The compiler didn't have enough information at the call site.
13+
14+
## Remarks
15+
16+
This error can occur when you call a forward-declared member function that has an **`auto`** return type but no body or trailing return type. You can also get this error when the compiler can't find a candidate return type when it instantiates a template specialization. A common cause of this error is a missing interface header. The missing type can often be determined from the typename mentioned in a note that follows this error. To resolve this issue, for every type you use, include the header for the namespace the type is in.
17+
18+
## Examples
19+
20+
The following C++/WinRT sample generates C3779:
21+
22+
```cpp
23+
// C3779.cpp
24+
#include <winrt/Windows.Gaming.Input.h>
25+
26+
void CheckGamepads()
27+
{
28+
auto gamepads =
29+
winrt::Windows::Gaming::Input::Gamepad::Gamepads();
30+
for (auto&& gamepad : gamepads)
31+
{
32+
check(gamepad);
33+
}
34+
}
35+
```
36+
37+
This code reports an error:
38+
39+
```Console
40+
C3779.cpp(8): error C3779: winrt::impl::consume_Windows_Foundation_Collections_IIterable<D,winrt::Windows::Gaming::Input::Gamepad>::First': a function that returns 'auto' cannot be used before it is defined
41+
with
42+
[
43+
D=winrt:::Windows:::Gaming:::Input:::Gamepad
44+
]
45+
note: see declaration of 'winrt::impl::consume_Windows_Foundation_Collections_IIterable<D,winrt::Windows::Gaming::Input::Gamepad>::First'
46+
with
47+
[
48+
D=winrt::Windows::Gaming::Input::IVisualCollection
49+
]
50+
```
51+
52+
The note implies that the return type definition depends on `Windows::Foundation::Collections::IIterable`. To resolve the issue, include the header for its containing namespace:
53+
54+
```cpp
55+
// C3779b.cpp
56+
#include <winrt/Windows.Foundation.Collections.h>
57+
#include <winrt/Windows.Gaming.Input.h>
58+
59+
void CheckGamepads()
60+
{
61+
auto gamepads =
62+
winrt::Windows::Gaming::Input::Gamepad::Gamepads();
63+
for (auto&& gamepad : gamepads)
64+
{
65+
check(gamepad);
66+
}
67+
}
68+
```
69+
70+
## See also
71+
72+
[Consume APIs with C++/WinRT](/windows/uwp/cpp-and-winrt-apis/consume-apis)\
73+
[Why does my C++/WinRT project get errors of the form "consume_Something: function that returns 'auto' cannot be used before it is defined"?](https://devblogs.microsoft.com/oldnewthing/20190530-00/?p=102529)

docs/error-messages/compiler-errors-2/compiler-errors-c3500-through-c3999.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: "Learn more about: Compiler errors C3500 through C3999"
33
title: "Compiler errors C3500 through C3999"
44
ms.date: "04/21/2019"
5-
f1_keywords: ["C3502", "C3503", "C3504", "C3511", "C3512", "C3513", "C3514", "C3515", "C3516", "C3517", "C3518", "C3520", "C3521", "C3522", "C3523", "C3524", "C3525", "C3526", "C3527", "C3528", "C3529", "C3534", "C3542", "C3543", "C3544", "C3545", "C3546", "C3547", "C3548", "C3549", "C3557", "C3558", "C3559", "C3560", "C3561", "C3562", "C3563", "C3564", "C3565", "C3566", "C3567", "C3568", "C3569", "C3570", "C3571", "C3572", "C3573", "C3574", "C3575", "C3576", "C3577", "C3578", "C3579", "C3580", "C3581", "C3582", "C3583", "C3584", "C3585", "C3586", "C3587", "C3588", "C3589", "C3590", "C3591", "C3592", "C3593", "C3594", "C3595", "C3596", "C3597", "C3598", "C3599", "C3600", "C3601", "C3602", "C3604", "C3605", "C3613", "C3614", "C3616", "C3620", "C3621", "C3635", "C3636", "C3649", "C3658", "C3659", "C3660", "C3663", "C3664", "C3667", "C3674", "C3676", "C3677", "C3678", "C3679", "C3680", "C3681", "C3682", "C3683", "C3684", "C3685", "C3686", "C3687", "C3688", "C3689", "C3690", "C3691", "C3696", "C3716", "C3720", "C3725", "C3726", "C3729", "C3730", "C3735", "C3742", "C3746", "C3750", "C3751", "C3756", "C3757", "C3758", "C3759", "C3760", "C3770", "C3773", "C3774", "C3775", "C3776", "C3777", "C3778", "C3779", "C3780", "C3781", "C3782", "C3783", "C3784", "C3785", "C3786", "C3787", "C3801", "C3802", "C3806", "C3811", "C3814", "C3819", "C3822", "C3823", "C3826", "C3827", "C3829", "C3837", "C3840", "C3841", "C3843", "C3844", "C3845", "C3863", "C3870", "C3871", "C3875", "C3879", "C3881", "C3882", "C3884", "C3885", "C3897", "C3905", "C3906", "C3916", "C3921", "C3924", "C3925", "C3926", "C3927", "C3928", "C3930", "C3931", "C3932", "C3933", "C3934", "C3935", "C3936", "C3937", "C3938", "C3939", "C3940", "C3941", "C3945", "C3946", "C3947", "C3948", "C3949", "C3950", "C3951", "C3952", "C3953", "C3954", "C3955", "C3956", "C3957", "C3958", "C3959", "C3960", "C3961", "C3962", "C3963", "C3964", "C3965", "C3966", "C3967", "C3968", "C3969", "C3970", "C3971", "C3972", "C3975", "C3976", "C3977", "C3978", "C3979", "C3980", "C3981", "C3982", "C3983", "C3984", "C3985", "C3986", "C3987", "C3988", "C3989", "C3990", "C3991", "C3992", "C3993", "C3994", "C3995", "C3996", "C3997", "C3998", "C3999"]
5+
f1_keywords: ["C3502", "C3503", "C3504", "C3511", "C3512", "C3513", "C3514", "C3515", "C3516", "C3517", "C3518", "C3520", "C3521", "C3522", "C3523", "C3524", "C3525", "C3526", "C3527", "C3528", "C3529", "C3534", "C3542", "C3543", "C3544", "C3545", "C3546", "C3547", "C3548", "C3549", "C3557", "C3558", "C3559", "C3560", "C3561", "C3562", "C3563", "C3564", "C3565", "C3566", "C3567", "C3568", "C3569", "C3570", "C3571", "C3572", "C3573", "C3574", "C3575", "C3576", "C3577", "C3578", "C3579", "C3580", "C3581", "C3582", "C3583", "C3584", "C3585", "C3586", "C3587", "C3588", "C3589", "C3590", "C3591", "C3592", "C3593", "C3594", "C3595", "C3596", "C3597", "C3598", "C3599", "C3600", "C3601", "C3602", "C3604", "C3605", "C3613", "C3614", "C3616", "C3620", "C3621", "C3635", "C3636", "C3649", "C3658", "C3659", "C3660", "C3663", "C3664", "C3667", "C3674", "C3676", "C3677", "C3678", "C3679", "C3680", "C3681", "C3682", "C3683", "C3684", "C3685", "C3686", "C3687", "C3688", "C3689", "C3690", "C3691", "C3696", "C3716", "C3720", "C3725", "C3726", "C3729", "C3730", "C3735", "C3742", "C3746", "C3750", "C3751", "C3756", "C3757", "C3758", "C3759", "C3760", "C3770", "C3773", "C3774", "C3775", "C3776", "C3777", "C3778", "C3780", "C3781", "C3782", "C3783", "C3784", "C3785", "C3786", "C3787", "C3801", "C3802", "C3806", "C3811", "C3814", "C3819", "C3822", "C3823", "C3826", "C3827", "C3829", "C3837", "C3840", "C3841", "C3843", "C3844", "C3845", "C3863", "C3870", "C3871", "C3875", "C3879", "C3881", "C3882", "C3884", "C3885", "C3897", "C3905", "C3906", "C3916", "C3921", "C3924", "C3925", "C3926", "C3927", "C3928", "C3930", "C3931", "C3932", "C3933", "C3934", "C3935", "C3936", "C3937", "C3938", "C3939", "C3940", "C3941", "C3945", "C3946", "C3947", "C3948", "C3949", "C3950", "C3951", "C3952", "C3953", "C3954", "C3955", "C3956", "C3957", "C3958", "C3959", "C3960", "C3961", "C3962", "C3963", "C3964", "C3965", "C3966", "C3967", "C3968", "C3969", "C3970", "C3971", "C3972", "C3975", "C3976", "C3977", "C3978", "C3979", "C3980", "C3981", "C3982", "C3983", "C3984", "C3985", "C3986", "C3987", "C3988", "C3989", "C3990", "C3991", "C3992", "C3993", "C3994", "C3995", "C3996", "C3997", "C3998", "C3999"]
66
ms.assetid: bd6f23ad-b300-4e07-8e35-9661cab1585f
77
---
88
# Compiler errors C3500 through C3999
@@ -294,8 +294,8 @@ The articles in this section of the documentation explain a subset of the error
294294
|Compiler error C3776|cannot return an expresssion of type void in a coroutine with non-void eventual return type|
295295
|Compiler error C3777|'*function*': a coroutine cannot take a variable argument list|
296296
|Compiler error C3778|alloca: cannot be used in a coroutine|
297-
|Compiler error C3779|'*function*': a function that returns '*type*' cannot be used before it is defined|
298-
|Compiler error C3780|'*function*': a conversion function that returns '*type*' cannot be used before it is defined|
297+
|[Compiler error C3779](compiler-error-c3779.md)|'*function*': a function that returns '*auto*' cannot be used before it is defined|
298+
|Compiler error C3780|'*function*': a conversion function that returns '*auto*' cannot be used before it is defined|
299299
|Compiler error C3781|'*keyword*': cannot be a used in a coroutine of type '*type*'. Either *keyword* or *keyword* must be present in associated promise_type|
300300
|Compiler error C3782|*type*: a coroutine's promise cannot contain both *keyword* and *keyword*|
301301
|Compiler error C3783|'*identifier*': cannot be a coroutine|

docs/error-messages/toc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,8 @@
29322932
href: compiler-errors-2/compiler-error-c3771.md
29332933
- name: Compiler error C3772
29342934
href: compiler-errors-2/compiler-error-c3772.md
2935+
- name: Compiler error C3779
2936+
href: compiler-errors-2/compiler-error-c3779.md
29352937
- name: Compiler error C3797
29362938
href: compiler-errors-2/compiler-error-c3797.md
29372939
- name: Compiler error C3798

0 commit comments

Comments
 (0)